package main import ( "Cold_DeductionNotice/Nats" "Cold_DeductionNotice/TimeMonitor" "Cold_DeductionNotice/conf" "Cold_DeductionNotice/logs" _ "Cold_DeductionNotice/routers" "github.com/beego/beego/v2/adapter/orm" beego "github.com/beego/beego/v2/server/web" _ "github.com/go-sql-driver/mysql" "strconv" ) func init() { orm.RegisterDriver("mysql", orm.DRMySQL) orm.RegisterDataBase("default", "mysql", conf.MysqlServer_Username+":"+conf.MysqlServer_Password+"@tcp("+conf.MysqlServer_UrlPort+")/"+conf.MysqlServer_Database+"?charset=utf8mb4&loc=Local&parseTime=True", conf.MysqlServer_MaxIdleConnections, conf.MysqlServer_MaxOpenConnections) orm.RunSyncdb("default", false, false) // 创建数据库 //logs.Println("MysqlServer:" + conf.MysqlServer_Username + ":" + conf.MysqlServer_Password + "@tcp(" + conf.MysqlServer_UrlPort + ")/" + conf.MysqlServer_Database + "?charset=utf8mb4&loc=Local&parseTime=True") } func main() { beego.BConfig.AppName = conf.AppName + "_" + strconv.Itoa(conf.HTTPPort) // 项目名 beego.BConfig.ServerName = conf.AppName + "_" + strconv.Itoa(conf.HTTPPort) //server 名称 beego.BConfig.RunMode = "dev" // 应用的运行模式 beego.BConfig.Listen.HTTPPort = conf.HTTPPort //监听端口 本地:8518 线上:8528 logs.Println("MqttServer", " ======= 项目启动 ========") go Nats.NatsInit() // Nats 通讯 go TimeMonitor.DeductionNoticeInit() // 定时 通知扣费 beego.Run() }