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

systemd on linux - add KillMode, KillSignal and TimeoutStopSec #387

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

avoidik
Copy link

@avoidik avoidik commented Dec 28, 2023

hello,

with this PR I would like to introduce these new [Service] scoped flags:

  • KillMode
  • KillSignal
  • TimeoutStopSec

addresses:

related PRs:

@luoxiaohei
Copy link

@kardianos

I believe this pull request is useful. Could you please take a look at it and consider merging it soon?

Thanks!

@kardianos
Copy link
Owner

Can you doc the new specific flags? Will changing these, such as Kill mode, etc, alter how the service, by default works? What values should it expect?

@luoxiaohei
Copy link

Hi @kardianos,

Thank you for your feedback. Just to confirm, are you requesting that detailed documentation be added to the pull request, such as annotations and descriptions for the new options? Or are you expecting the definition of some global variables to declare the available values and default values for each option?


To provide some context, here are brief explanations of these flags, along with their default values and expected ranges:

  • KillMode: Determines how processes of a service should be killed when the service is stopped.

    • Default value: control-group
    • Expected values:
      • control-group: All processes in the control group are killed.
      • process: Only the main process is killed.
      • mixed: Main process is killed with KillSignal, and remaining processes are killed with SIGKILL.
      • none: No processes are killed.
  • KillSignal: Specifies which signal should be sent to the service's main process when it is being stopped.

    • Default value: SIGTERM
    • Expected values: Any valid Unix signal, such as SIGTERM, SIGKILL, SIGINT, SIGHUP, etc.
  • TimeoutStopSec: Sets the time to wait for a service to stop after sending the termination signal before forcibly killing it.

    • Default value: 90 seconds
    • Expected values: Any valid time duration, such as 30s (30 seconds), 5min (5 minutes), 1h (1 hour), etc.

@kardianos
Copy link
Owner

On on the fence on Timeout Stop Sec.

The Kill signal, that would probably interfere with the current implementation of func (s *systemd) Run() (err error) {

The KillMode, I'm not sure when you wouldn't want to have control-group, for a multi-platform service system.

Where is this need coming from? More broadly, I would be inclined to make separate system packages that have many options, such as systemd, then have service package be a generic package, with perhaps a system specific use cases.
If you know you are going to use systemd, maybe just use it directly.

@avoidik
Copy link
Author

avoidik commented Jun 15, 2024

@kardianos it's quite good summary, I understand your desire to keep this package simple and as generic as possible, without implementing edge-case logic specific to downstream solutions, alternatively, you have left an option to be able to render our own custom template for units, in case of systemd it's called "SystemdScript", if we absolutely sure we'd want to use systemd this option is what we need, however this part hasn't been described in details

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.

3 participants