|
123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package main
-
- import (
- "applet/app/cfg"
- "applet/app/db"
- "applet/app/utils"
- "applet/app/utils/logx"
- "applet/consume"
- "fmt"
- "os"
- "os/signal"
- "syscall"
- )
-
- // 系统初始化
- func init() {
- cfg.InitCfg() //配置初始化
- cfg.InitLog() //日志初始化
- cfg.InitCache() //缓存初始化
- cfg.InitMq() //队列初始化
- if cfg.Debug { //判断是否是debug
- if err := db.InitDB(cfg.DB); err != nil { //主数据库初始化
- panic(err)
- }
- }
- fmt.Println("init success")
- }
-
- func main() {
- if cfg.CurlDebug {
- utils.CurlDebug = true
- }
-
- go func() {
- // 初始化
- consume.Init()
- consume.Run()
- }()
-
- quit := make(chan os.Signal)
- signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
- <-quit
- _ = logx.Info("Server exiting...")
-
- }
|