Skip to content

Commit

Permalink
feat: restart services failed within okay delay
Browse files Browse the repository at this point in the history
  • Loading branch information
IronCore864 committed Nov 6, 2024
1 parent b783466 commit eeec47b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions internals/overlord/servstate/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,15 @@ func (s *serviceData) exited(exitCode int) error {

switch s.state {
case stateStarting:
s.started <- fmt.Errorf("exited quickly with code %d", exitCode)
s.transition(stateExited) // not strictly necessary as doStart will return, but doesn't hurt
action, onType := getAction(s.config, exitCode == 0)
if action == plan.ActionRestart {
// Restart services failed within the okay delay period.
s.started <- fmt.Errorf("exited quickly with code %d; auto-restart is enabled, Pebble will keep trying to start it", exitCode)
s.doBackoff(action, onType)
} else {
s.started <- fmt.Errorf("exited quickly with code %d", exitCode)
s.transition(stateExited) // not strictly necessary as doStart will return, but doesn't hurt
}

case stateRunning:
logger.Noticef("Service %q stopped unexpectedly with code %d", s.config.Name, exitCode)
Expand Down

0 comments on commit eeec47b

Please sign in to comment.