Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow stopping services in "starting" state #503

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions internals/overlord/servstate/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,10 @@ func (s *serviceData) stop() error {
defer s.manager.servicesLock.Unlock()

switch s.state {
case stateStarting:
s.started <- fmt.Errorf("stopped before the 1 second okay delay")
IronCore864 marked this conversation as resolved.
Show resolved Hide resolved
fallthrough

case stateRunning:
logger.Debugf("Attempting to stop service %q by sending SIGTERM", s.config.Name)
// First send SIGTERM to try to terminate it gracefully.
Expand Down
2 changes: 1 addition & 1 deletion internals/overlord/servstate/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ func servicesToStop(m *ServiceManager) ([][]string, error) {
var notStopped []string
for _, name := range services {
s := m.services[name]
if s != nil && (s.state == stateRunning || s.state == stateBackoff) {
if s != nil && (s.state == stateStarting || s.state == stateRunning || s.state == stateBackoff) {
notStopped = append(notStopped, name)
}
}
Expand Down
1 change: 1 addition & 0 deletions internals/overlord/servstate/state-diagram.dot
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ digraph service_state_machine {
node [penwidth=1]
initial -> starting [label="start"]
starting -> running [label="okay wait\nelapsed"]
starting -> terminating [label="stopped before\nokay wait elapses"]
IronCore864 marked this conversation as resolved.
Show resolved Hide resolved
running -> terminating [label="stop"]
running -> terminating [label="check failed\n(action \"restart\")"]
terminating -> killing [label="terminate time\nelapsed"]
Expand Down
Loading
Loading