Unobtrusive support windows services

Does your long lived command look like a standard unix service? Want to run it on windows?
import _ "github.com/kardianos/minwinsvc"

This one line will allow your executable to be run as a windows service. It is a noop on other platforms (but still compiles). It registers and maintains callbacks that windows services require. You can install using normal windows tools like:
sc create "ServiceName" binPath= "executable path"
(there is a space between the β€œ=” and the parameter value)

Windows by default sets the CWD to C:\windows\system32 and you can’t set env vars. But you can set command line arguments when installing.

Might be useful to people needing a quick way to run unix services on windows with almost no modification.

5 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.