Commit 9b54ace3 authored by Lei Li's avatar Lei Li
Browse files

feat: 增加常量字符串

parent 29dfbe5b
......@@ -5,7 +5,7 @@ import "time"
var (
WorkDir = "/linkfog/agent/"
LogDir = WorkDir + "/log"
LogDir = "log"
LogFileName = "agent.log"
DaemonLogFileName = "agent_daemon.log"
......@@ -19,7 +19,5 @@ var (
MonitorLogUnModDuration = 600 * time.Second
BinDir = WorkDir + "/bin"
SelfOperatedAndroid = "/data/smallp"
BinDir = "bin"
)
......@@ -30,12 +30,21 @@ type Agent struct {
func (a *Agent) Init(env svc.Environment) error {
option.Parse()
// 获取平台和内核版本
global.GetPlatformInfo()
// 设置工作目录
err := global.SetWorkDir()
if err != nil {
return err
}
if option.Opt.EnableMonitorDaemon {
config.LogFileName = config.DaemonLogFileName
}
// 日志设置
err := l.SetConfig(l.Config{
err = l.SetConfig(l.Config{
Path: filepath.Join(config.LogDir, config.LogFileName),
MaxSize: int64(option.Opt.LogMaxSizeKB),
MaxRolls: option.Opt.LogRollNum,
......@@ -120,16 +129,8 @@ func genVersion() string {
func initSvcCfg() error {
// 获取平台和内核版本
global.GetPlatformInfo()
// 设置工作目录
err := global.SetWorkDir()
if err != nil {
return err
}
// 异常情况处理
if _, err := os.Stat(config.SelfOperatedAndroid); os.IsExist(err) {
if _, err := os.Stat(global.SelfOperatedAndroid); os.IsExist(err) {
l.Infof("the host is a self operated Android device")
for {
time.Sleep(24 * time.Hour)
......
......@@ -74,11 +74,15 @@ func SetWorkDir() error {
if err != nil {
return err
}
err = os.MkdirAll(path.Join(config.LogDir), 0644)
config.LogDir = path.Join(config.WorkDir, config.LogDir)
err = os.MkdirAll(config.LogDir, 0644)
if err != nil {
return err
}
err = os.MkdirAll(path.Join(config.BinDir), 0644)
config.BinDir = path.Join(config.WorkDir, config.BinDir)
err = os.MkdirAll(config.BinDir, 0644)
if err != nil {
return err
}
......
package global
const (
DeviceIDFile = ".deviceID"
DeviceRegisterFIle = ".reg2lw.lock"
DeviceVendorCodeFIle = "..org_code"
SpeedLockFile = ".speedLock"
SpeedFile = ".speed"
SelfOperatedAndroid = "/data/smallp"
WgetURL = "https://cdn2.bkdomain.cn/test/0411/android-agent-server2/wget"
Dcs9994URL = "https://newdcs.bkdomain.cn:9994"
DcsRegisterDevAPI = "/api/v1/xsaas/reg"
DcsGetSeqAPI = "/api/v4/sds/getTimeSeq"
DcsUploadBandwidthAPIV2 = "/api/v2/xsaas/bw"
DcsFixBandwidthAPI = "/api/v4/sds/fixBandwidth"
DcsUploadBandWidthDetails = "/api/v4/sds/uploadBandwidthDetails"
Dcs9942URL = "https://newdcs.bkdomain.cn:9992"
DcsUploadFlowDeviceAPI = "/api/v4/sds/uploadFlowDevice"
HmacKey = "4N][zmn;bPW!a>F~iU+["
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment