1 Star 0 Fork 204

realfloat/openGW

forked from shiyin1211/openGW 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 2.01 KB
一键复制 编辑 原始数据 按行查看 历史
package main
import (
"goAdapter/device"
"goAdapter/httpServer"
"goAdapter/report"
"goAdapter/setting"
"os"
"os/signal"
"syscall"
"github.com/fatih/color"
"github.com/robfig/cron"
// _ "net/http/pprof"
)
func main() {
/**************获取配置文件***********************/
setting.GetConf()
/**************日志初始化***********************/
setting.InitLogger()
//记录起始时间
setting.GetTimeStart()
setting.ZAPS.Infof("%s %s", setting.SystemState.Name, color.RedString(setting.SystemState.SoftVer))
setting.MemoryDataStream = setting.NewDataStreamTemplate("内存使用率")
setting.DiskDataStream = setting.NewDataStreamTemplate("硬盘使用率")
setting.DeviceOnlineDataStream = setting.NewDataStreamTemplate("设备在线率")
setting.DevicePacketLossDataStream = setting.NewDataStreamTemplate("通信丢包率")
/**************网口初始化***********************/
setting.NetworkParaRead()
setting.GetNetworkParam()
/**************变量模板初始化****************/
device.DeviceTSLInit()
device.CollectInterfaceInit()
/**************NTP校时初始化****************/
setting.NTPInit()
/**************创建定时获取网络状态的任务***********************/
// 定义一个cron运行器
cronProcess := cron.New()
// 定时5秒,每5秒执行print5
_ = cronProcess.AddFunc("*/5 * * * * *", setting.GetNetworkParam)
// 定时60秒,定时获取系统信息
_ = cronProcess.AddFunc("*/60 * * * * *", setting.CollectSystemParam)
// 每天0点,定时获取NTP服务器的时间,并校时
_ = cronProcess.AddFunc("0 0 0 * * ?", func() {
setting.NTPGetTime()
})
cronProcess.Start()
defer cronProcess.Stop()
report.ReportServiceInit()
//go func() {
// http.ListenAndServe("0.0.0.0:8090", nil)
//}()
httpServer.RouterWeb(setting.HttpPort)
setting.ZAPS.Info("openGW 初始化成功!")
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
select {
case <-signalChan:
setting.ZAPS.Infof("openGW程序退出")
return
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/realfloat/goAdapter.git
git@gitee.com:realfloat/goAdapter.git
realfloat
goAdapter
openGW
develop

搜索帮助

0d507c66 1850385 C8b1a773 1850385