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

Provide WinSW Service Manager #13

Merged
merged 3 commits into from Nov 5, 2023

Conversation

jacderida
Copy link
Contributor

  • 91bd9d0 Provide the WinSW service manager

    WinSW is a useful tool that can wrap any application as a Windows service; it provides the
    boilerplate code for interacting with the service infrastructure on Windows. You define a
    configuration for your application service in XML, then use WinSW, along with your configuration, as
    a service controller.

    The full specification for the service configuration can be found here:
    https://github.com/winsw/winsw/blob/v3/samples/complete.xml

    In this initial implementation, we provide support for most of the available elements, with the
    exception of:

    • serviceaccount
    • startarguments (I don't know what the difference is between that and 'arguments')
    • workingdirectory
    • logpath and log
    • env
    • download
    • extensions

    Support for workingdirectory and env will follow in subsequent commits; these fields can be added to
    the generic ServiceInstallCtx since they are common options on all platforms.

    Most of the code here deals with building the configuration file. This code was written as a
    separate function so that the different options could be unit tested. There is an integration/system
    test in a similar fashion to the sc manager.

  • e1844e2 Extend ServiceInstallCtx with new options

    It is very common to define a working directory for a service process and a list of environment
    variables to pass to the process when it runs. The ServiceInstallCtx is extended for this because
    it applies to most service managers.

    In this particular case, three of the managers have been extended to support the variables: Systemd,
    Launchd and WinSW. The Windows sc.exe service manager does not support specifying either. The
    other two unix-based service managers might, but I am not familiar with those at the present time.
    It should be easy enough to extend them with a further PR.

WinSW is a useful tool that can wrap any application as a Windows service; it provides the
boilerplate code for interacting with the service infrastructure on Windows. You define a
configuration for your application service in XML, then use WinSW, along with your configuration, as
a service controller.

The full specification for the service configuration can be found here:
https://github.com/winsw/winsw/blob/v3/samples/complete.xml

In this initial implementation, we provide support for most of the available elements, with the
exception of:

* serviceaccount
* startarguments (I don't know what the difference is between that and 'arguments')
* workingdirectory
* logpath and log
* env
* download
* extensions

Support for workingdirectory and env will follow in subsequent commits; these fields can be added to
the generic `ServiceInstallCtx` since they are common options on all platforms.

Most of the code here deals with building the configuration file. This code was written as a
separate function so that the different options could be unit tested. There is an integration/system
test in a similar fashion to the sc manager.
It is very common to define a working directory for a service process and a list of environment
variables to pass to the process when it runs. The `ServiceInstallCtx` is extended for this because
it applies to most service managers.

In this particular case, three of the managers have been extended to support the variables: Systemd,
Launchd and WinSW. The Windows `sc.exe` service manager does not support specifying either. The
other two unix-based service managers might, but I am not familiar with those at the present time.
It should be easy enough to extend them with a further PR.
@chipsenkbeil
Copy link
Owner

@jacderida gave it a skim and it all looks fine to me. 😄 Would you mind adding an update to the changelog? After that, I can merge this in.

@jacderida
Copy link
Contributor Author

@jacderida gave it a skim and it all looks fine to me. 😄 Would you mind adding an update to the changelog? After that, I can merge this in.

Thanks.

I should have remembered to do that this time! I've now pushed an extra commit with the CHANGELOG update.

@chipsenkbeil chipsenkbeil merged commit bf30b30 into chipsenkbeil:main Nov 5, 2023
12 checks passed
@valtyr
Copy link

valtyr commented Nov 6, 2023

Hey there. Do you guys have an ETA for when this will be released?

@chipsenkbeil
Copy link
Owner

@valtyr it's released now as version 0.5.0.

@valtyr
Copy link

valtyr commented Nov 6, 2023

Amazing! Thank you so much. I found this library today and it's perfect for my use case, these changes make it even better!

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.

None yet

3 participants