Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Lei Li
agent
Commits
9b54ace3
Commit
9b54ace3
authored
Oct 16, 2024
by
Lei Li
Browse files
feat: 增加常量字符串
parent
29dfbe5b
Changes
4
Show whitespace changes
Inline
Side-by-side
cmd/agent/config/config.go
View file @
9b54ace3
...
@@ -5,7 +5,7 @@ import "time"
...
@@ -5,7 +5,7 @@ import "time"
var
(
var
(
WorkDir
=
"/linkfog/agent/"
WorkDir
=
"/linkfog/agent/"
LogDir
=
WorkDir
+
"/
log"
LogDir
=
"
log"
LogFileName
=
"agent.log"
LogFileName
=
"agent.log"
DaemonLogFileName
=
"agent_daemon.log"
DaemonLogFileName
=
"agent_daemon.log"
...
@@ -19,7 +19,5 @@ var (
...
@@ -19,7 +19,5 @@ var (
MonitorLogUnModDuration
=
600
*
time
.
Second
MonitorLogUnModDuration
=
600
*
time
.
Second
BinDir
=
WorkDir
+
"/bin"
BinDir
=
"bin"
SelfOperatedAndroid
=
"/data/smallp"
)
)
cmd/agent/core/agent.go
View file @
9b54ace3
...
@@ -30,12 +30,21 @@ type Agent struct {
...
@@ -30,12 +30,21 @@ type Agent struct {
func
(
a
*
Agent
)
Init
(
env
svc
.
Environment
)
error
{
func
(
a
*
Agent
)
Init
(
env
svc
.
Environment
)
error
{
option
.
Parse
()
option
.
Parse
()
// 获取平台和内核版本
global
.
GetPlatformInfo
()
// 设置工作目录
err
:=
global
.
SetWorkDir
()
if
err
!=
nil
{
return
err
}
if
option
.
Opt
.
EnableMonitorDaemon
{
if
option
.
Opt
.
EnableMonitorDaemon
{
config
.
LogFileName
=
config
.
DaemonLogFileName
config
.
LogFileName
=
config
.
DaemonLogFileName
}
}
// 日志设置
// 日志设置
err
:
=
l
.
SetConfig
(
l
.
Config
{
err
=
l
.
SetConfig
(
l
.
Config
{
Path
:
filepath
.
Join
(
config
.
LogDir
,
config
.
LogFileName
),
Path
:
filepath
.
Join
(
config
.
LogDir
,
config
.
LogFileName
),
MaxSize
:
int64
(
option
.
Opt
.
LogMaxSizeKB
),
MaxSize
:
int64
(
option
.
Opt
.
LogMaxSizeKB
),
MaxRolls
:
option
.
Opt
.
LogRollNum
,
MaxRolls
:
option
.
Opt
.
LogRollNum
,
...
@@ -120,16 +129,8 @@ func genVersion() string {
...
@@ -120,16 +129,8 @@ func genVersion() string {
func
initSvcCfg
()
error
{
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"
)
l
.
Infof
(
"the host is a self operated Android device"
)
for
{
for
{
time
.
Sleep
(
24
*
time
.
Hour
)
time
.
Sleep
(
24
*
time
.
Hour
)
...
...
cmd/agent/global/global.go
View file @
9b54ace3
...
@@ -74,11 +74,15 @@ func SetWorkDir() error {
...
@@ -74,11 +74,15 @@ func SetWorkDir() error {
if
err
!=
nil
{
if
err
!=
nil
{
return
err
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
{
if
err
!=
nil
{
return
err
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
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
cmd/agent/global/service.go
0 → 100644
View file @
9b54ace3
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+["
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment