fix: 更新restagent为omc

This commit is contained in:
TsMask
2025-04-01 18:44:35 +08:00
parent e02707cd0e
commit 01df7b745b
8 changed files with 12 additions and 12 deletions

View File

@@ -66,7 +66,7 @@ ssh -P 18122 root@192.168.9.58 # arm64 ubuntu:18.04
```sh ```sh
# 安装 Go版本 1.21.6 后进入项目根目录 # 安装 Go版本 1.21.6 后进入项目根目录
cd ./restagent cd /ems_backend
# 下载依赖 # 下载依赖
go mod download 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 init -d ./ -g main.go -o ./swagger_docs
swag fmt -d ./ -g main.go swag fmt -d ./ -g main.go
# 打包命名 restagent # 打包命名 omc
go build -ldflags="-s -w" -o omc go build -ldflags="-s -w" -o omc
``` ```

View File

@@ -863,7 +863,7 @@ func PostNeServiceAction(w http.ResponseWriter, r *http.Request) {
// send 204 to fe firstly // send 204 to fe firstly
services.ResponseStatusOK204NoContent(w) services.ResponseStatusOK204NoContent(w)
//actionCmd := fmt.Sprintf("sudo %s/bin/omcsvc.sh %s", config.GetYamlConfig().NE.OmcDir, action) //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) go RunSSHCmd(sshHost, actionCmd)
return return
// cmd := exec.Command("ssh", sshHost, actionCmd) // cmd := exec.Command("ssh", sshHost, actionCmd)

View File

@@ -483,7 +483,7 @@ func ReadTestConfigYaml(pfile string) (ret error) {
} }
func GetDefaultUserAgent() string { func GetDefaultUserAgent() string {
return "OMC-restagent/" + global.Version return "OMC/" + global.Version
} }
func GetOMCHostUrl() string { func GetOMCHostUrl() string {

View File

@@ -6,7 +6,7 @@ serverVersion: "std"
# duration: rotation time with xx hours, example: 1/12/24 hours # duration: rotation time with xx hours, example: 1/12/24 hours
# count: rotation count of log, default is 30 rotation # count: rotation count of log, default is 30 rotation
logger: logger:
file: /usr/local/omc/log/restagent.log file: /usr/local/omc/log/omc.log
level: warn level: warn
duration: 24 duration: 24
count: 90 count: 90

View File

@@ -161,9 +161,9 @@ func loadFeatures(app *gin.Engine) {
conf := featuresCfg.GetYamlConfig() conf := featuresCfg.GetYamlConfig()
log.InitLogger(conf.Logger.File, conf.Logger.Duration, conf.Logger.Count, "omc:restagent", featuresCfg.GetLogLevel()) log.InitLogger(conf.Logger.File, conf.Logger.Duration, conf.Logger.Count, "omc:restagent", featuresCfg.GetLogLevel())
fmt.Printf("OMC restagent version: %s\n", config.Version) fmt.Printf("OMC Version: %s\n", config.Version)
log.Infof("========================= OMC restagent startup =========================") log.Infof("========================= OMC Startup =========================")
log.Infof("OMC restagent version: %s %s %s", config.Version, config.BuildTime, config.GoVer) log.Infof("OMC Version: %s %s %s", config.Version, config.BuildTime, config.GoVer)
mml.InitMML() mml.InitMML()

View File

@@ -163,11 +163,11 @@ func Reset() error {
// return fmt.Errorf("not support window") // return fmt.Errorf("not support window")
} else { } 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 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 return err
} }
} }

View File

@@ -427,7 +427,7 @@ func (s *NeActionController) Service(c *gin.Context) {
neTypeLower := strings.ToLower(neInfo.NeType) neTypeLower := strings.ToLower(neInfo.NeType)
cmdStr := fmt.Sprintf("sudo service %s %s", neTypeLower, body.Action) cmdStr := fmt.Sprintf("sudo service %s %s", neTypeLower, body.Action)
if neTypeLower == "omc" { 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" { } else if neTypeLower == "ims" {
if body.Action == "restart" { if body.Action == "restart" {
cmdStr = "ims-stop || true && ims-start" cmdStr = "ims-stop || true && ims-start"

View File

@@ -182,7 +182,7 @@ func (r *NeLicense) UploadLicense(neLicense model.NeLicense) error {
if neTypeLower == "ims" { if neTypeLower == "ims" {
cmdStr = "ims-stop || true && ims-start" cmdStr = "ims-stop || true && ims-start"
} else if neTypeLower == "omc" { } else if neTypeLower == "omc" {
cmdStr = "sudo systemctl restart restagent" cmdStr = "sudo systemctl restart omc"
} }
sshClient.RunCMD(cmdStr) sshClient.RunCMD(cmdStr)
} }