Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bugs #51

Merged
merged 2 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 10 additions & 17 deletions libcs/client/web/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (
"github.com/isrc-cas/gt/web/server/model/request"
"github.com/isrc-cas/gt/web/server/model/response"
"github.com/isrc-cas/gt/web/server/util"
"os"
"os/exec"
)

func HealthCheck(ctx *gin.Context) {
Expand Down Expand Up @@ -183,24 +181,10 @@ func SaveConfigToFile(c *client.Client) gin.HandlerFunc {
}
c.Logger.Info().Str("config", fullPath).Msg("save config to file")

err = ReloadServicesCommand(c)
if err != nil {
response.FailWithMessage(err.Error(), ctx)
return
}
Reload(ctx)
response.SuccessWithMessage("save config to "+fullPath, ctx)
}
}
func ReloadServicesCommand(c *client.Client) (err error) {
execPath := os.Args[0]
command := exec.Command(execPath, "-s", "reload")
_, err = command.CombinedOutput()
if err != nil {
c.Logger.Logger.Info().Msg("failed to exec command-reload:" + err.Error())
return
}
return
}

// Restart for a brand-new config process,
// not only reload the services,
Expand All @@ -214,6 +198,15 @@ func Restart(ctx *gin.Context) {
response.Success(ctx)
}

func Reload(ctx *gin.Context) {
err := util.SendSignal("reload")
if err != nil {
response.FailWithMessage(err.Error(), ctx)
return
}
response.Success(ctx)
}

func Stop(ctx *gin.Context) {
err := util.SendSignal("stop")
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions libcs/web/front/src/languages/lang/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export namespace zh {
Local: "本地服务的 URL",
LocalURL: "本地服务的 URL",
LocalTimeout: "本地连接的超时时间。支持值如 '30s'、'5m'",
UseLocalAsHTTPHost: "使用本地主机作为GT-Server主机",
UseLocalAsHTTPHost: "使用本地URL作为HTTP Header Host的值",

// Sentry 设置
SentryDSN: "要使用的 Sentry DSN",
Expand Down Expand Up @@ -238,7 +238,7 @@ export namespace zh {
RemoteTCPRandom: "GT-Server TCP随机端口",
LocalURL: "本地 URL",
LocalTimeout: "本地连接超时时间",
UseLocalAsHTTPHost: "使用本地主机运行GT-Server",
UseLocalAsHTTPHost: "HTTP Header Host替换",
TcpForwardAddr: "TCP 转发地址",
TcpForwardHostPrefix: "TCP 转发主机前缀",
TcpForwardConnections: "TCP 转发连接数",
Expand Down
Loading