Provide Generic RestartPolicy Enum#39
Merged
jacderida merged 2 commits intochipsenkbeil:mainfrom Dec 8, 2025
Merged
Conversation
I found myself in a situation where I need to use the 'always' and 'on success' restart policies on Linux Systemd and macOS Launchd. It was not possible to do this while using the generic `ServiceManager` trait; I would have to use specific service managers, which would necessitate the introduction of conditional compilation. Now we introduce a generic `RestartPolicy` enum to work with the generic `ServiceManager` trait. This should cover the most important cases supported by most service managers: 'never', 'always', and 'on failure', plus the option for 'on success'. Users can still instantiate a particular service manager if they want to use specific restart options that are only supported by that manager. In some cases these variants don't map directly to some service manager options, so an approximation is used and a warning is emitted; however, it should still be very acceptable to configure the service in this way since the behaviour should not be too surprising. See the changelog entry for more details. BREAKING CHANGE: the `disable_restart_on_failure` field was removed in favour of the restart policy and the fields on specific service managers were made optional.
Collaborator
Author
|
Just wanted to note, both of these tests were failing on the last merged PR. I think the failures are probably unrelated to my changes. I manually tested creating a user-mode service on macOS as part of my application that uses the crate. It worked fine. |
Owner
|
@jacderida we can merge and figure out these failures separately. Do you have time to help me look into the macos failure? |
Collaborator
Author
Hey Chip, that's great, thanks. I will merge and publish soon. I don't have time to look into it right now, but I have holiday from work in about 2 weeks. I promise I will take some time to look into it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
51ed396 feat!: provide generic
RestartPolicyenumI found myself in a situation where I need to use the 'always' and 'on success' restart policies on
Linux Systemd and macOS Launchd. It was not possible to do this while using the generic
ServiceManagertrait; I would have to use specific service managers, which would necessitate theintroduction of conditional compilation.
Now we introduce a generic
RestartPolicyenum to work with the genericServiceManagertrait.This should cover the most important cases supported by most service managers: 'never', 'always',
and 'on failure', plus the option for 'on success'. Users can still instantiate a particular service
manager if they want to use specific restart options that are only supported by that manager.
In some cases these variants don't map directly to some service manager options, so an approximation
is used and a warning is emitted; however, it should still be very acceptable to configure the
service in this way since the behaviour should not be too surprising.
See the changelog entry for more details.
BREAKING CHANGE: the
disable_restart_on_failurefield was removed in favour of the restart policyand the fields on specific service managers were made optional.
d0d2bc6 chore(release): bump to version 0.9.0