main.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package main
  2. import (
  3. _ "Cold_Monitor/Nats"
  4. "Cold_Monitor/conf"
  5. _ "Cold_Monitor/routers"
  6. "github.com/beego/beego/v2/adapter/orm"
  7. beego "github.com/beego/beego/v2/server/web"
  8. _ "github.com/go-sql-driver/mysql"
  9. "strconv"
  10. )
  11. func init() {
  12. orm.RegisterDriver("mysql", orm.DRMySQL)
  13. orm.RegisterDataBase("default", "mysql",
  14. conf.MysqlServer_Username+":"+conf.MysqlServer_Password+"@tcp("+conf.MysqlServer_UrlPort+")/"+conf.MysqlServer_Database+"?charset=utf8mb4&loc=Local&parseTime=True",
  15. conf.MysqlServer_MaxIdleConnections, conf.MysqlServer_MaxOpenConnections)
  16. orm.RunSyncdb("default", false, true) // 创建数据库
  17. //logs.Println("MysqlServer:" + conf.MysqlServer_Username + ":" + conf.MysqlServer_Password + "@tcp(" + conf.MysqlServer_UrlPort + ")/" + conf.MysqlServer_Database + "?charset=utf8mb4&loc=Local&parseTime=True")
  18. }
  19. func main() {
  20. beego.BConfig.AppName = conf.AppName + "_" + strconv.Itoa(conf.HTTPPort) // 项目名
  21. beego.BConfig.ServerName = conf.AppName + "_" + strconv.Itoa(conf.HTTPPort) //server 名称
  22. beego.BConfig.RunMode = "dev" // 应用的运行模式
  23. beego.BConfig.Listen.HTTPPort = conf.HTTPPort //监听端口 本地:8518 线上:8528
  24. println(conf.HTTPPort)
  25. //go TimeTask.Init() // 时间任务
  26. beego.Run()
  27. }
  28. /*
  29. 冷链 动环监控
  30. https://gogs.baozhida.cn/bzdadmin/Cold_Monitor.git
  31. */