Open lethedata opened 2 months ago
I don't think we should change the default behaviour at this point but I can see an argument for having a different DSL to accomplish what you'd want.
CC @SMillerDev for thoughts.
IIRC there is a different keepalive parameter for this, where it only keeps the service alive on failures.
I'm also not that excited about optimising something in brew service
so that you can manage them outside of brew, since that's not really a goal for brew service
in my opinion.
IIRC there is a different keepalive parameter for this, where it only keeps the service alive on failures.
Well now I'm a bit confused. I went back and looked and found reference to different states under the Formula Cookbook but it looks like other states aren't implemented on a systemd generation? I'm like 99% sure I'm missing something here. I'll try testing it when I have sometime later today.
I'm also not that excited about optimising something in brew service so that you can manage them outside of brew, since that's not really a goal for brew service in my opinion.
I can agree with that. Figured I'd ask as I struggled to think of a use case where always restart makes since on desktop and now that you mention it I can see wanting to avoid management drift.
Well now I'm a bit confused. I went back and looked and found reference to different states under the Formula Cookbook but it looks like other states aren't implemented on a systemd generation? I'm like 99% sure I'm missing something here. I'll try testing it when I have sometime later today.
It is possible that I never implemented all options for systemd.
@lethedata Thanks for the link! In that case: yes, this should definitely be implemented.
Verification
brew install wget
. If they do, open an issue at https://github.com/Homebrew/homebrew-core/issues/new/choose instead.Provide a detailed description of the proposed feature
When brew generates a systemd unit file with
keep_alive true
in the formula, it generates withRestart=always
which prevents manually killing the service with systemctl directly. By switching toRestart=on-failure
Linux users will be able to kill services with systemctl while still retaining a proper keep-alive functionality[^1]. This would also limit the need for brew to handle generating multiple exit codes (I think it was done this way due to a limitation on the MacOS side).I think this change only requires a single line be changed in the service.rb file but I'm not familiar enough the code to be sure. https://github.com/Homebrew/brew/blob/8c4c7319fc6ba3a69b1ba65659b03d418ebbfb2f/Library/Homebrew/service.rb#L475
[^1]: systemd.service manual
What is the motivation for the feature?
Being unable to kill a service with
systemctl
as a workaround to thebrew services kill
keep-alive limitation. The service only needed to be temporarily killed, not completely disabled, and being unable to manually kill it seemed a bit odd.How will the feature be relevant to at least 90% of Homebrew users?
It will allow Linux users manually kill services with
systemctl stop --user homebrew.SERVICENAME.service
without needing to fully disable the service.What alternatives to the feature have been considered?
I wasn't able to find any previous discussion but but an alternative would be to have brew handle multiple exit states within the keep-alive but I think this would diverge the Linux and MacOS side requiring quite a bit of change.