代码拉取完成,页面将自动刷新
同步操作将从 shiyin1211/openGW 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package main
import (
"fmt"
"github.com/robfig/cron"
"goAdapter/device"
"goAdapter/httpServer"
"goAdapter/report"
"goAdapter/setting"
)
func main() {
/**************获取配置文件***********************/
setting.GetConf()
setting.LogerInit(setting.LogLevel, setting.LogSaveToFile, setting.LogFileMaxCnt)
//记录起始时间
setting.GetTimeStart()
setting.Logger.Info("goteway V0.0.1")
setting.MemoryDataStream = setting.NewDataStreamTemplate("内存使用率")
setting.DiskDataStream = setting.NewDataStreamTemplate("硬盘使用率")
setting.DeviceOnlineDataStream = setting.NewDataStreamTemplate("设备在线率")
setting.DevicePacketLossDataStream = setting.NewDataStreamTemplate("通信丢包率")
/**************网口初始化***********************/
setting.NetworkParaRead()
setting.NetworkParamList.GetNetworkParam()
/**************变量模板初始化****************/
device.DeviceNodeManageInit()
/**************NTP校时初始化****************/
setting.NTPInit()
/**************创建定时获取网络状态的任务***********************/
// 定义一个cron运行器
cronProcess := cron.New()
// 定时5秒,每5秒执行print5
_ = cronProcess.AddFunc("*/5 * * * * *", setting.NetworkParamList.GetNetworkParam)
// 定时
for k, v := range device.CollectInterfaceMap {
device.CommunicationManage = append(device.CommunicationManage, device.NewCommunicationManageTemplate(v))
//CommunicationManage.CollInterfaceName = v.CollInterfaceName
str := fmt.Sprintf("@every %dm%ds", v.PollPeriod/60, v.PollPeriod%60)
setting.Logger.Infof("str %+v", str)
_ = cronProcess.AddFunc(str, device.CommunicationManage[k].CommunicationManagePoll)
go device.CommunicationManage[k].CommunicationManageDel()
}
// 定时60秒,定时获取系统信息
_ = cronProcess.AddFunc("*/60 * * * * *", setting.CollectSystemParam)
// 每天0点,定时获取NTP服务器的时间,并校时
_ = cronProcess.AddFunc("0 0 0 * * ?", func() {
setting.NTPGetTime()
})
// 定时60秒,mqtt发布消息
//cronGetNetStatus.AddFunc("*/30 * * * * *", mqttClient.MqttAppPublish)
cronProcess.Start()
defer cronProcess.Stop()
report.ReportServiceInit()
for _, v := range device.CommunicationManage {
v.CommunicationManagePoll()
}
httpServer.RouterWeb()
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。