fix: 更新restagent为omc
This commit is contained in:
@@ -66,7 +66,7 @@ ssh -P 18122 root@192.168.9.58 # arm64 ubuntu:18.04
|
||||
|
||||
```sh
|
||||
# 安装 Go版本 1.21.6 后进入项目根目录
|
||||
cd ./restagent
|
||||
cd /ems_backend
|
||||
# 下载依赖
|
||||
go mod download
|
||||
|
||||
@@ -85,7 +85,7 @@ go tool pprof -http=:9090 http://127.0.0.1:33060/debug/pprof/heap
|
||||
swag init -d ./ -g main.go -o ./swagger_docs
|
||||
swag fmt -d ./ -g main.go
|
||||
|
||||
# 打包命名 restagent
|
||||
# 打包命名 omc
|
||||
go build -ldflags="-s -w" -o omc
|
||||
```
|
||||
|
||||
|
||||
@@ -863,7 +863,7 @@ func PostNeServiceAction(w http.ResponseWriter, r *http.Request) {
|
||||
// send 204 to fe firstly
|
||||
services.ResponseStatusOK204NoContent(w)
|
||||
//actionCmd := fmt.Sprintf("sudo %s/bin/omcsvc.sh %s", config.GetYamlConfig().NE.OmcDir, action)
|
||||
actionCmd := fmt.Sprintf("sudo systemctl %s restagent", action)
|
||||
actionCmd := fmt.Sprintf("sudo systemctl %s omc", action)
|
||||
go RunSSHCmd(sshHost, actionCmd)
|
||||
return
|
||||
// cmd := exec.Command("ssh", sshHost, actionCmd)
|
||||
|
||||
@@ -483,7 +483,7 @@ func ReadTestConfigYaml(pfile string) (ret error) {
|
||||
}
|
||||
|
||||
func GetDefaultUserAgent() string {
|
||||
return "OMC-restagent/" + global.Version
|
||||
return "OMC/" + global.Version
|
||||
}
|
||||
|
||||
func GetOMCHostUrl() string {
|
||||
|
||||
@@ -6,7 +6,7 @@ serverVersion: "std"
|
||||
# duration: rotation time with xx hours, example: 1/12/24 hours
|
||||
# count: rotation count of log, default is 30 rotation
|
||||
logger:
|
||||
file: /usr/local/omc/log/restagent.log
|
||||
file: /usr/local/omc/log/omc.log
|
||||
level: warn
|
||||
duration: 24
|
||||
count: 90
|
||||
|
||||
6
main.go
6
main.go
@@ -161,9 +161,9 @@ func loadFeatures(app *gin.Engine) {
|
||||
conf := featuresCfg.GetYamlConfig()
|
||||
|
||||
log.InitLogger(conf.Logger.File, conf.Logger.Duration, conf.Logger.Count, "omc:restagent", featuresCfg.GetLogLevel())
|
||||
fmt.Printf("OMC restagent version: %s\n", config.Version)
|
||||
log.Infof("========================= OMC restagent startup =========================")
|
||||
log.Infof("OMC restagent version: %s %s %s", config.Version, config.BuildTime, config.GoVer)
|
||||
fmt.Printf("OMC Version: %s\n", config.Version)
|
||||
log.Infof("========================= OMC Startup =========================")
|
||||
log.Infof("OMC Version: %s %s %s", config.Version, config.BuildTime, config.GoVer)
|
||||
|
||||
mml.InitMML()
|
||||
|
||||
|
||||
@@ -163,11 +163,11 @@ func Reset() error {
|
||||
// return fmt.Errorf("not support window")
|
||||
} else {
|
||||
// 重置数据库
|
||||
if _, err := cmd.Execf("/usr/local/omc/bin/setomc.sh -m install"); err != nil {
|
||||
if _, err := cmd.Execf("/usr/local/etc/omc/script/setup.sh -i"); err != nil {
|
||||
return err
|
||||
}
|
||||
// 重启服务
|
||||
if _, err := cmd.Execf("nohup sh -c \"sleep 1s && %s\" > /dev/null 2>&1 &", "sudo systemctl restart restagent"); err != nil {
|
||||
if _, err := cmd.Execf("nohup sh -c \"sleep 1s && %s\" > /dev/null 2>&1 &", "sudo systemctl restart omc"); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -427,7 +427,7 @@ func (s *NeActionController) Service(c *gin.Context) {
|
||||
neTypeLower := strings.ToLower(neInfo.NeType)
|
||||
cmdStr := fmt.Sprintf("sudo service %s %s", neTypeLower, body.Action)
|
||||
if neTypeLower == "omc" {
|
||||
cmdStr = fmt.Sprintf("nohup sh -c \"sudo systemctl stop restagent && sleep 5s && sudo systemctl %s restagent\" > /dev/null 2>&1 &", body.Action)
|
||||
cmdStr = fmt.Sprintf("nohup sh -c \"sudo systemctl stop omc && sleep 5s && sudo systemctl %s omc\" > /dev/null 2>&1 &", body.Action)
|
||||
} else if neTypeLower == "ims" {
|
||||
if body.Action == "restart" {
|
||||
cmdStr = "ims-stop || true && ims-start"
|
||||
|
||||
@@ -182,7 +182,7 @@ func (r *NeLicense) UploadLicense(neLicense model.NeLicense) error {
|
||||
if neTypeLower == "ims" {
|
||||
cmdStr = "ims-stop || true && ims-start"
|
||||
} else if neTypeLower == "omc" {
|
||||
cmdStr = "sudo systemctl restart restagent"
|
||||
cmdStr = "sudo systemctl restart omc"
|
||||
}
|
||||
sshClient.RunCMD(cmdStr)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user