@@ -10,8 +10,6 @@ import (
1010 "github.com/isrc-cas/gt/web/server/model/request"
1111 "github.com/isrc-cas/gt/web/server/model/response"
1212 "github.com/isrc-cas/gt/web/server/util"
13- "os"
14- "os/exec"
1513)
1614
1715func HealthCheck (ctx * gin.Context ) {
@@ -183,24 +181,10 @@ func SaveConfigToFile(c *client.Client) gin.HandlerFunc {
183181 }
184182 c .Logger .Info ().Str ("config" , fullPath ).Msg ("save config to file" )
185183
186- err = ReloadServicesCommand (c )
187- if err != nil {
188- response .FailWithMessage (err .Error (), ctx )
189- return
190- }
184+ Reload (ctx )
191185 response .SuccessWithMessage ("save config to " + fullPath , ctx )
192186 }
193187}
194- func ReloadServicesCommand (c * client.Client ) (err error ) {
195- execPath := os .Args [0 ]
196- command := exec .Command (execPath , "-s" , "reload" )
197- _ , err = command .CombinedOutput ()
198- if err != nil {
199- c .Logger .Logger .Info ().Msg ("failed to exec command-reload:" + err .Error ())
200- return
201- }
202- return
203- }
204188
205189// Restart for a brand-new config process,
206190// not only reload the services,
@@ -214,6 +198,15 @@ func Restart(ctx *gin.Context) {
214198 response .Success (ctx )
215199}
216200
201+ func Reload (ctx * gin.Context ) {
202+ err := util .SendSignal ("reload" )
203+ if err != nil {
204+ response .FailWithMessage (err .Error (), ctx )
205+ return
206+ }
207+ response .Success (ctx )
208+ }
209+
217210func Stop (ctx * gin.Context ) {
218211 err := util .SendSignal ("stop" )
219212 if err != nil {
0 commit comments