|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- 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() //队列初始化
- cfg.InitEs() //ElasticSearch初始化
- if cfg.Debug { //判断是否是debug
- if err := db.InitDB(cfg.DB); err != nil { //主数据库初始化
- panic(err)
- }
- channel := make(chan int, 0) //开辟管道,缓冲为
- go db.InitDBs(channel)
- <-channel
- }
- 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...")
-
- }
|