Skip to content

Commit

Permalink
backdoor restart delay (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
teckick authored Mar 24, 2021
1 parent 50c155f commit b472a06
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions util/service/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,13 @@ func FactoryRestart() xhttp.HandleRequest {

func (m *Restart) Handle(r *xhttp.HttpRequest) xhttp.HttpResponse {
xlog.Infof(context.Background(), "RECEIVE RESTART COMMAND")
server.sbase.Stop()
os.Exit(1)
// 这里的代码执行不到了,因为之前已经退出了
// 延迟退出, 保证接口正常返回
go func() {
time.Sleep(1 * time.Second)
server.sbase.Stop()
os.Exit(1)
}()

return xhttp.NewHttpRespString(200, "{}")
}

Expand Down

0 comments on commit b472a06

Please sign in to comment.