package main import ( "fmt" "os" "os/signal" "syscall" "applet/app/cfg" "applet/app/db" "applet/app/task" "applet/app/utils" "applet/app/utils/logx" ) func init() { // 加载任务配置 cfg.InitTaskCfg() // 日志配置 cfg.InitLog() // 初始化redis cfg.InitCache() baseDb := *cfg.DB baseDb.Path = fmt.Sprintf(cfg.DB.Path, cfg.DB.Name) if err := db.InitDB(&baseDb); err != nil { panic(err) } dataDb := *cfg.DataDB dataDb.Path = fmt.Sprintf(cfg.DataDB.Path, cfg.DataDB.Name) if err := db.InitDataDB(&dataDb); err != nil { panic(err) } imDb := *cfg.ImDB imDb.Path = fmt.Sprintf(cfg.ImDB.Path, cfg.ImDB.Name) if err := db.InitImDB(&imDb); err != nil { panic(err) } utils.CurlDebug = true //cfg.InitMemCache() } func main() { go func() { // 初始化jobs方法列表、添加reload方法定时更新任务 task.Init() task.Run() }() // graceful shutdown quit := make(chan os.Signal) signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM) <-quit _ = logx.Info("Server exiting...") }