zhangqian
2023-11-01 443fb992699818305e3d7f6885ca7d1d36fbe7cd
conf/config.go
@@ -4,8 +4,11 @@
   "apsClient/pkg/convertx"
   "apsClient/pkg/logx"
   "apsClient/pkg/sqlitex"
   "apsClient/pkg/timex"
   "apsClient/utils"
   "github.com/spf13/viper"
   "log"
   "time"
)
var (
@@ -104,7 +107,11 @@
      CurrentDeviceID string //设置当前面板控制的设备
      SerfClusterStatus string
      SerfClusterStatus string //集群状态
      ClusterNodeQuantity int //集群节点数量
      SystemDeviceRunSince int64 //系统开始运行时间戳
   }
)
@@ -130,6 +137,19 @@
   if Conf.PLC.StandbyTime == 0 {
      Conf.PLC.StandbyTime = 300 //5分钟
   }
   uptimeStr, err := utils.Exec("uptime -s")
   if err == nil {
      t, err := timex.StringToTime(uptimeStr)
      if err == nil {
         Conf.SystemDeviceRunSince = t.Unix()
      }
   } else {
      Conf.SystemDeviceRunSince = time.Now().Unix()
   }
   SetUpTime()
   ShowConfig()
}
@@ -150,3 +170,15 @@
   log.Printf("   services :                  %+v", Conf.Services)
   log.Println("......................................................")
}
func SetUpTime() {
   uptimeStr, err := utils.Exec("uptime -s")
   if err == nil {
      t, err := timex.StringToTime(uptimeStr)
      if err == nil {
         Conf.SystemDeviceRunSince = t.Unix()
      }
   } else {
      Conf.SystemDeviceRunSince = time.Now().Unix()
   }
}