fix: restagent改omc

This commit is contained in:
TsMask
2024-08-31 14:38:10 +08:00
parent c139bbad94
commit 2be150c9ae
5 changed files with 8 additions and 45 deletions

View File

@@ -862,7 +862,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)

View File

@@ -31,48 +31,6 @@ import (
"golang.org/x/net/http2/h2c"
)
// const defaultConfigFile = "./etc/restconf.yaml"
// func init() {
// cfile := flag.String("c", defaultConfigFile, "config file")
// pv := flag.Bool("v", false, "print version")
// ph := flag.Bool("h", false, "print help")
// flag.Parse()
// if *pv {
// fmt.Printf("OMC restagent version: %s\n%s\n%s\n\n", global.Version, global.BuildTime, global.GoVer)
// os.Exit(0)
// }
// if *ph {
// flag.Usage()
// os.Exit(0)
// }
// config.ReadConfig(*cfile)
// config.UriPrefix = config.GetYamlConfig().OMC.UriPrefix
// //fmt.Println(config.UriPrefix)
// }
// func listenIPv6(ipv6 string, port int) {
// //
// addr := &net.TCPAddr{
// IP: net.ParseIP(ipv6),
// Port: port,
// }
// listener, err := net.ListenTCP("tcp6", addr)
// if err != nil {
// fmt.Println("Failed to listen:", err)
// return
// }
// server := &http.Server{}
// err = server.Serve(listener)
// if err != nil {
// fmt.Println("Failed to serve:", err)
// }
// }
func HttpListen(addr string, router http.Handler) {
// 创建HTTP服务器
h2s := &http2.Server{

View File

@@ -98,7 +98,10 @@ func initAppEngine() *gin.Engine {
// 初始全局默认
func initDefeat(app *gin.Engine) {
// 全局中间件
app.Use(errorcatch.ErrorCatch(), middleware.Report(), middleware.Cors(), security.Security())
if config.Env() == "local" {
app.Use(middleware.Report())
}
app.Use(errorcatch.ErrorCatch(), middleware.Cors(), security.Security())
// 静态目录-静态资源
if v := config.Get("staticFile.default"); v != nil {

View File

@@ -167,7 +167,7 @@ func Reset() error {
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
}
}

View File

@@ -52,6 +52,7 @@ func Setup(router *gin.Engine) {
// Count: 10,
// Type: middleware.LIMIT_IP,
// }),
middleware.CryptoApi(true, true),
controller.NewAccount.Login,
)
indexGroup.GET("/getInfo", middleware.PreAuthorize(nil), controller.NewAccount.Info)
@@ -74,6 +75,7 @@ func Setup(router *gin.Engine) {
// Count: 10,
// Type: middleware.LIMIT_IP,
// }),
middleware.CryptoApi(true, true),
controller.NewRegister.Register,
)
}