package main import ( "Yunlot/RunCode" "Yunlot/TimeTask" "Yunlot/conf" "Yunlot/logs" _ "Yunlot/routers" "github.com/beego/beego/v2/adapter/orm" orm2 "github.com/beego/beego/v2/client/orm" beego "github.com/beego/beego/v2/server/web" _ "github.com/go-sql-driver/mysql" _ "github.com/mattn/go-sqlite3" //_ "github.com/logoove/sqlite" "strconv" ) func init() { //orm.RegisterDriver("sqlite", orm.DRSqlite) //orm.RegisterDataBase("default", "sqlite3", "./models/data.db") //orm.RunSyncdb("default", false, true) logs.Println("MysqlServer:" + conf.MysqlServer_Username + ":" + conf.MysqlServer_Password + "@tcp(" + conf.MysqlServer_UrlPort + ")/" + conf.MysqlServer_Database + "?charset=utf8mb4&loc=Local&parseTime=True") 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, 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 orm2.Debug = true logs.Println("MqttServer", " ======= 项目启动 ========") //go MqttServer2.Run_MqttServer() // MQTT 通讯 //go MqttServer.MqttPolling() // MQTT 设备轮询 //go MqttServer.DeviceMqttMap_go() //// 缓存数据发送-确保设备在休眠后 能收到数据 //go Nats.NatsInit() // Nats 通讯 go TimeTask.Init() // 时间任务 go RunCode.RunCode_Inte() // 代码编译 beego.Run() }