|
- package main
-
- import (
- db "code.fnuoos.com/zhimeng/model.git/src"
- "fmt"
- "os"
- "os/signal"
- "syscall"
-
- "applet/app/cfg"
- "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)
- }
- 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...")
- }
|