feat app 模块化启动
This commit is contained in:
@@ -2,10 +2,16 @@ package app
|
||||
|
||||
import (
|
||||
"common/db/etcd"
|
||||
"common/log"
|
||||
"scene/config"
|
||||
)
|
||||
|
||||
func (p *Program) initDB(cfg *config.Config) error {
|
||||
// ModuleDB 数据库模块
|
||||
type ModuleDB struct {
|
||||
}
|
||||
|
||||
func (p *ModuleDB) Init() error {
|
||||
cfg := config.Get()
|
||||
// ETCD
|
||||
if err := etcd.Init(cfg.DB.Etcd.Address); err != nil {
|
||||
return err
|
||||
@@ -13,8 +19,13 @@ func (p *Program) initDB(cfg *config.Config) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Program) stopDB() error {
|
||||
_ = etcd.Close()
|
||||
|
||||
func (p *ModuleDB) Start() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *ModuleDB) Stop() error {
|
||||
if err := etcd.Close(); err != nil {
|
||||
log.Errorf("close etcd failed: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user