judwhite / go-svc

Go Windows Service wrapper that plays nice with Linux.
MIT License
481 stars 85 forks source link

Support running under NSSM #6

Open judwhite opened 7 years ago

judwhite commented 7 years ago

If the binary isn't running under Service Control Manager (SCM), then StartServiceCtrlDispatcher() will fail with ERROR_FAILED_SERVICE_CONTROLLER_CONNECT. This is a more reliable way of detecting if a service is running under SCM than checking svc.IsAnInteractiveSession. Checking the IsAnInteractiveSession value first can be an optimization to avoid skipping the StartServiceCtrlDispatcher error check.

In Go, svc.Run should fail here calling windows.StartServiceCtrlDispatcher.

Troubleshooting tips, if needed: http://stackoverflow.com/a/30719534 (from 2015-05-26)

judwhite commented 3 years ago

This may be resolved by 8134bf01874a0eb77bf2375bd317e0d2bfcb70d0, needs investigation