Skip to content

Conversation

@jabr
Copy link
Contributor

@jabr jabr commented Dec 2, 2025

Basic implementation of service start/stop commands from #183.

The linter isn't happy with the duplication, but I'm not sure the best way to deal with that while also keeping with project conventions... edit: ignoring linter complaints about duplication for these commands.

@jabr jabr force-pushed the service-start-stop branch from ca9b794 to 5f51eff Compare December 3, 2025 06:22
Copy link
Owner

@psviderski psviderski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! What do you think about supporting the timeout and signal flags for stop like docker stop supports?
We can address this in the follow-up PR if you like but would be good to do this to not come back to stop in the near future. Just let me know.

Regarding start, I can't think of anything immediately necessary.

@jabr
Copy link
Contributor Author

jabr commented Dec 8, 2025

Good call on the stop signal/timeout options. Added.

}
if opts.timeout != 0 {
stopOpts.Timeout = &opts.timeout
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this behaviour is different to the default docker's behaviour of --timeout. Please see https://github.com/docker/cli/blob/master/cli/command/container/stop.go#L60-L64 how it handles when --timeout is not set or not (.Changed("timeout")).

Note that 0 is valid value that is different to nil: https://github.com/moby/moby/blob/8068dfb686a09fa66a577a4b94646d15349802dc/client/container_stop.go#L16-L24

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use the same flag Changed check to set the timeout option properly.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

},
}
cmd.Flags().StringVarP(&opts.signal, "signal", "s", "", "Signal to send to the container")
cmd.Flags().IntVarP(&opts.timeout, "timeout", "t", 0, "Seconds to wait before killing the container")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I kept the "default" 0 here as that's what the docker code does: https://github.com/docker/cli/blob/master/cli/command/container/stop.go#L48

@psviderski psviderski merged commit a9a720f into psviderski:main Dec 9, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants