jordansissel / pleaserun

An attempt to abstract this "init" script madness.
Other
1.17k stars 80 forks source link

Windows service support #18

Open jordansissel opened 10 years ago

haf commented 10 years ago

This one is finicky. You probably need a wrapper because Windows isn't file-based.

  1. Ensure wrapper available next to executable
  2. Generate xml
  3. rename winsw.exe -> myservice.exe
  4. myservice.exe install
jordansissel commented 10 years ago

You can use powershell (and batch, if you're crazy) to add new windows services. See Powershell's New-Service http://technet.microsoft.com/en-us/library/hh849830.aspx

Basically, get some credentials (Get-Credentials) and pass them to New-Service and boom you've got a service.

You can also do it with the older sc command, but powershell's interface is much nicer to work with, imo.

My idea here is that pleaserun for windows will create a powershell script to run that installs the service; powershell for reusability outside the host generating it ;)

igalic commented 10 years ago

is there no way to call the .Net API behind New-Service directly, rather than relying on Powershell as a mediator?

jordansissel commented 10 years ago

@igalic My thoughts on this were that pleaserun should output a thing you can install somewhere else.

So, if pleaserun can only be run on the system you are installing a service on, I think it misses a useful case where you could package a 'service'.

For example, we could package an init script or a systemd service configuration, so I think it makes sense to be able to provide a packagable windows service output, and that probably means a powershell script or something exportable to the host you want to run it on.

At least, that's my thinking, anyway.

A long-term project idea is to have a webapp that you can say "Make me a service configuration that does X" and it hands you a script to do it. If pleaserun was required to run on your system itself, this would fall down a bit ;)