MCPcopy
hub / github.com/cubefs/cubefs / Start

Method Start

authnode/server.go:187–234  ·  view source on GitHub ↗

Start starts a server

(cfg *config.Config)

Source from the content-addressed store, hash-verified

185
186// Start starts a server
187func (m *Server) Start(cfg *config.Config) (err error) {
188 m.config = newClusterConfig()
189 m.leaderInfo = &LeaderInfo{}
190 if err = m.checkConfig(cfg); err != nil {
191 log.LogError(errors.Stack(err))
192 return
193 }
194 if m.rocksDBStore, err = raftstore_db.NewRocksDBStore(m.storeDir, LRUCacheSize, WriteBufferSize); err != nil {
195 log.LogErrorf("Start: init RocksDB fail: err(%v)", err)
196 return
197 }
198
199 if err = m.createRaftServer(cfg); err != nil {
200 log.LogError(errors.Stack(err))
201 return
202 }
203 m.initCluster()
204 m.cluster.partition = m.partition
205
206 AuthSecretKey := cfg.GetString(AuthSecretKey)
207 if m.cluster.AuthSecretKey, err = cryptoutil.Base64Decode(AuthSecretKey); err != nil {
208 return fmt.Errorf("action[Start] failed %v,err: auth service Key invalid=%s", proto.ErrInvalidCfg, AuthSecretKey)
209 }
210
211 AuthRootKey := cfg.GetString(AuthRootKey)
212 if m.cluster.AuthRootKey, err = cryptoutil.Base64Decode(AuthRootKey); err != nil {
213 return fmt.Errorf("action[Start] failed %v,err: auth root Key invalid=%s", proto.ErrInvalidCfg, AuthRootKey)
214 }
215
216 if cfg.GetBool(EnableHTTPS) {
217 m.cluster.PKIKey.EnableHTTPS = true
218 if m.cluster.PKIKey.AuthRootPublicKey, err = os.ReadFile("/app/server.crt"); err != nil {
219 return fmt.Errorf("action[Start] failed,err[%v]", err)
220 }
221 if m.cluster.PKIKey.AuthRootPrivateKey, err = os.ReadFile("/app/server.key"); err != nil {
222 return fmt.Errorf("action[Start] failed,err[%v]", err)
223 }
224 // TODO: verify cert
225 } else {
226 m.cluster.PKIKey.EnableHTTPS = false
227 }
228 m.authProxy = m.newAuthProxy()
229 exporter.RegistConsul(m.clusterName, cfg.GetString("role"), cfg)
230 m.cluster.scheduleTask()
231 m.startHTTPService()
232 m.wg.Add(1)
233 return nil
234}
235
236// Shutdown closes the server
237func (m *Server) Shutdown() {

Callers

nothing calls this directly

Calls 15

checkConfigMethod · 0.95
createRaftServerMethod · 0.95
initClusterMethod · 0.95
newAuthProxyMethod · 0.95
startHTTPServiceMethod · 0.95
LogErrorFunction · 0.92
StackFunction · 0.92
NewRocksDBStoreFunction · 0.92
LogErrorfFunction · 0.92
Base64DecodeFunction · 0.92
RegistConsulFunction · 0.92
newClusterConfigFunction · 0.70

Tested by

no test coverage detected