main.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package main
  2. import (
  3. "Cold_DeductionNotice/Nats"
  4. "Cold_DeductionNotice/TimeMonitor"
  5. "Cold_DeductionNotice/conf"
  6. "Cold_DeductionNotice/logs"
  7. _ "Cold_DeductionNotice/routers"
  8. "github.com/beego/beego/v2/adapter/orm"
  9. beego "github.com/beego/beego/v2/server/web"
  10. _ "github.com/go-sql-driver/mysql"
  11. "strconv"
  12. )
  13. func init() {
  14. orm.RegisterDriver("mysql", orm.DRMySQL)
  15. orm.RegisterDataBase("default", "mysql",
  16. conf.MysqlServer_Username+":"+conf.MysqlServer_Password+"@tcp("+conf.MysqlServer_UrlPort+")/"+conf.MysqlServer_Database+"?charset=utf8mb4&loc=Local&parseTime=True",
  17. conf.MysqlServer_MaxIdleConnections, conf.MysqlServer_MaxOpenConnections)
  18. orm.RunSyncdb("default", false, false) // 创建数据库
  19. //logs.Println("MysqlServer:" + conf.MysqlServer_Username + ":" + conf.MysqlServer_Password + "@tcp(" + conf.MysqlServer_UrlPort + ")/" + conf.MysqlServer_Database + "?charset=utf8mb4&loc=Local&parseTime=True")
  20. }
  21. func main() {
  22. beego.BConfig.AppName = conf.AppName + "_" + strconv.Itoa(conf.HTTPPort) // 项目名
  23. beego.BConfig.ServerName = conf.AppName + "_" + strconv.Itoa(conf.HTTPPort) //server 名称
  24. beego.BConfig.RunMode = "dev" // 应用的运行模式
  25. beego.BConfig.Listen.HTTPPort = conf.HTTPPort //监听端口 本地:8518 线上:8528
  26. logs.Println("MqttServer", " ======= 项目启动 ========")
  27. go Nats.NatsInit() // Nats 通讯
  28. go TimeMonitor.DeductionNoticeInit() // 定时 通知扣费
  29. beego.Run()
  30. }