Handle restarting correctly, ensure power state propagates correctly
This commit is contained in:
parent
b4875926c6
commit
956e87eb93
|
@ -134,7 +134,11 @@ func (e *Environment) Stop() error {
|
||||||
return e.Terminate(os.Kill)
|
return e.Terminate(os.Kill)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the process is already offline don't switch it back to stopping. Just leave it how
|
||||||
|
// it is and continue through to the stop handling for the process.
|
||||||
|
if e.State() != system.ProcessOfflineState {
|
||||||
e.setState(system.ProcessStoppingState)
|
e.setState(system.ProcessStoppingState)
|
||||||
|
}
|
||||||
|
|
||||||
// Only attempt to send the stop command to the instance if we are actually attached to
|
// Only attempt to send the stop command to the instance if we are actually attached to
|
||||||
// the instance. If we are not for some reason, just send the container stop event.
|
// the instance. If we are not for some reason, just send the container stop event.
|
||||||
|
@ -202,6 +206,14 @@ func (e *Environment) Terminate(signal os.Signal) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !c.State.Running {
|
if !c.State.Running {
|
||||||
|
// If the container is not running but we're not already in a stopped state go ahead
|
||||||
|
// and update things to indicate we should be completely stopped now. Set to stopping
|
||||||
|
// first so crash detection is not triggered.
|
||||||
|
if e.State() != system.ProcessOfflineState {
|
||||||
|
e.setState(system.ProcessStoppingState)
|
||||||
|
e.setState(system.ProcessOfflineState)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,9 +97,6 @@ func (s *Server) HandlePowerAction(action PowerAction, waitSeconds ...int) error
|
||||||
// too soon, and you can rack up all sorts of issues.
|
// too soon, and you can rack up all sorts of issues.
|
||||||
return s.Environment.WaitForStop(10*60, true)
|
return s.Environment.WaitForStop(10*60, true)
|
||||||
case PowerActionRestart:
|
case PowerActionRestart:
|
||||||
// Only try to wait for stop if the process is currently running, otherwise just skip right to the
|
|
||||||
// start event.
|
|
||||||
if r, _ := s.Environment.IsRunning(); !r {
|
|
||||||
if err := s.Environment.WaitForStop(10*60, true); err != nil {
|
if err := s.Environment.WaitForStop(10*60, true); err != nil {
|
||||||
// Even timeout errors should be bubbled back up the stack. If the process didn't stop
|
// Even timeout errors should be bubbled back up the stack. If the process didn't stop
|
||||||
// nicely, but the terminate argument was passed then the server is stopped without an
|
// nicely, but the terminate argument was passed then the server is stopped without an
|
||||||
|
@ -111,7 +108,6 @@ func (s *Server) HandlePowerAction(action PowerAction, waitSeconds ...int) error
|
||||||
// up.
|
// up.
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Now actually try to start the process by executing the normal pre-boot logic.
|
// Now actually try to start the process by executing the normal pre-boot logic.
|
||||||
if err := s.onBeforeStart(); err != nil {
|
if err := s.onBeforeStart(); err != nil {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user