mirror of https://github.com/shunfei/cronsun
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
526 B
40 lines
526 B
package cronsun
|
|
|
|
import (
|
|
"github.com/shunfei/cronsun/conf"
|
|
"github.com/shunfei/cronsun/db"
|
|
)
|
|
|
|
var (
|
|
initialized bool
|
|
)
|
|
|
|
func Init() (err error) {
|
|
if initialized {
|
|
return
|
|
}
|
|
|
|
// init id creator
|
|
if err = initID(); err != nil {
|
|
return
|
|
}
|
|
|
|
// init config
|
|
if err = conf.Init(); err != nil {
|
|
return
|
|
}
|
|
|
|
// init etcd client
|
|
if DefalutClient, err = NewClient(conf.Config); err != nil {
|
|
return
|
|
}
|
|
|
|
// init mongoDB
|
|
if mgoDB, err = db.NewMdb(conf.Config.Mgo); err != nil {
|
|
return
|
|
}
|
|
|
|
initialized = true
|
|
return
|
|
}
|