Skip to content

Provide Generic RestartPolicy Enum#39

Merged
jacderida merged 2 commits intochipsenkbeil:mainfrom
jacderida:generic_restart_policy
Dec 8, 2025
Merged

Provide Generic RestartPolicy Enum#39
jacderida merged 2 commits intochipsenkbeil:mainfrom
jacderida:generic_restart_policy

Conversation

@jacderida
Copy link
Collaborator

  • 51ed396 feat!: provide generic RestartPolicy enum

    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.

  • d0d2bc6 chore(release): bump to version 0.9.0

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.
@jacderida
Copy link
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.

@chipsenkbeil
Copy link
Owner

@jacderida we can merge and figure out these failures separately. Do you have time to help me look into the macos failure?

@jacderida
Copy link
Collaborator Author

@jacderida we can merge and figure out these failures separately. Do you have time to help me look into the macos failure?

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.

@jacderida jacderida merged commit 6eba67e into chipsenkbeil:main Dec 8, 2025
11 of 13 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