Skip to content

Allow systemctl stop on keep_alive services - Restart=on-failure #17639

Open
@lethedata

Description

@lethedata

Verification

Provide a detailed description of the proposed feature

When brew generates a systemd unit file with keep_alive true in the formula, it generates with Restart=always which prevents manually killing the service with systemctl directly. By switching to Restart=on-failure Linux users will be able to kill services with systemctl while still retaining a proper keep-alive functionality1. 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.

options << "Restart=always" if @keep_alive.present? && @keep_alive[:always].present?

What is the motivation for the feature?

Being unable to kill a service with systemctl as a workaround to the brew 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.

Footnotes

  1. systemd.service manual

Metadata

Metadata

Assignees

No one assigned

    Labels

    featuresNew featureshelp wantedWe want help addressing this

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions