Add support for restarting a server instance
This commit is contained in:
parent
019d028011
commit
5fd138e188
19
http.go
19
http.go
|
@ -190,7 +190,24 @@ func (rt *Router) routeServerPower(w http.ResponseWriter, r *http.Request, ps ht
|
|||
}
|
||||
break
|
||||
case "restart":
|
||||
break
|
||||
if err := s.Environment.WaitForStop(60, false); err != nil {
|
||||
zap.S().Errorw(
|
||||
"encountered unexpected error waiting for server process to stop",
|
||||
zap.Error(err),
|
||||
zap.String("server", s.Uuid),
|
||||
zap.String("action", "restart"),
|
||||
)
|
||||
}
|
||||
|
||||
if err := s.Environment.Start(); err != nil {
|
||||
zap.S().Errorw(
|
||||
"encountered unexpected error starting server process",
|
||||
zap.Error(err),
|
||||
zap.String("server", s.Uuid),
|
||||
zap.String("action", "restart"),
|
||||
)
|
||||
}
|
||||
break;
|
||||
case "kill":
|
||||
if err := s.Environment.Terminate(os.Kill); err != nil {
|
||||
zap.S().Errorw(
|
||||
|
|
|
@ -375,7 +375,13 @@ func (wsh *WebsocketHandler) HandleInbound(m WebsocketMessage) error {
|
|||
case "stop":
|
||||
return wsh.Server.Environment.Stop()
|
||||
case "restart":
|
||||
return nil
|
||||
{
|
||||
if err := wsh.Server.Environment.WaitForStop(60, false); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return wsh.Server.Environment.Start()
|
||||
}
|
||||
case "kill":
|
||||
return wsh.Server.Environment.Terminate(os.Kill)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user