Goploy-Agent编译部署过程及代码优化

行云流水
2022-10-30 / 0 评论 / 193 阅读 / 正在检测是否收录...

前言

在做测试的过程中,想实时关注下服务器状态,命令行工具界面比较难看。看够了,就想找一下有没有现成的,部署方便的单机监控。可以通过web界面展示当前服务状态,发现了 Goploy-Agent ,比较符合我的需求。启动也非常简单,特此记录使用过程。

配置

修改配置

env = 'production'

[goploy]
# goploy server url, empty to use it standalone
# reportURL = 'http://localhost:3001'
reportURL = ''
# The same as goploy.jwt.key in goploy.toml
#
key = '2021-12-17 10:44:44.5198737 +0800 CST m=+0.003999901'

# Support id | name | host
uidType = 'id'
uid = '1'

[log]
path = 'stdout'

[web]
port = '3002'

启动

screen ./goploy-agent

优化

修改代码

//controller/Controller.go  281行
            if !strings.HasPrefix(fields[0], "eth") && !strings.HasPrefix(fields[0], "em") && !strings.HasPrefix(fields[0], "lo") {
                continue
            }

//task/Task.go  363行
        if strings.HasPrefix(fields1[0], "eth") || strings.HasPrefix(fields1[0], "em"){
            logType = model.TypePubNet
        } else if strings.HasPrefix(fields1[0], "lo") {
            logType = model.TypeLoNet
        } else {
            continue
        }

重新编译

# 编译vue前端
cd web/ 
npm install vite
npm run build

# 编译go,然后将生成的二进制文件上传服务器替换即可
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build main.go

评论 (0)

取消
只有登录/注册用户才可评论