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

Feature request: Windows Service mode #163

Open
easymoney322 opened this issue Sep 5, 2023 · 4 comments
Open

Feature request: Windows Service mode #163

easymoney322 opened this issue Sep 5, 2023 · 4 comments

Comments

@easymoney322
Copy link

I'd like to see support for the service mode in Windows.
Right now, if you just make service, Windows will kill (Error 7000) the process on timeout (Error 7009).
Im unable to use task scheduler on some systems due to unstabilites, like when TS just finishes the task right after the start.
Docker containers wont work on old systems,
And computer startup scripts are the only workarounds, but are harder to control remotely.

@NiceGuyIT
Copy link
Member

How are you creating the service?

I wonder what other exporters use. 🤔 node_exporter recommends windows_exporter which uses an MSI for installation. dellhw_exporter uses sc.exe.

@easymoney322
Copy link
Author

I was creating it manually with PowerShell New-Service, and I think it doesn't really matter, since all the services are managed by Service Control Manager in the end.
The service works fine for ~30s, before SCM kills it for not responding to the system calls.
This timeout is set at global level and can't be changed for any service individually.

Windows_exporter works fine, is able to work as a service, and creates one during the installation. Same goes for OHM-Graphite.

If I understood Microsoft's Docs correctly, support for an app to work as a service must be implemented in the executable itself. For C++ it would be made via "winsvc.h". I don't know how it can be implemented with Go language, as I have no experience with Go.
I'd suggest reading this golang/go#23479

How are you creating the service?

I wonder what other exporters use. 🤔 node_exporter recommends windows_exporter which uses an MSI for installation. dellhw_exporter uses sc.exe.

@Informatic
Copy link
Contributor

One fairly simple workaround for this (and a correct solution if some application you want to run doesn't implement Windows service protocol) would be using something like nssm.

@easymoney322
Copy link
Author

easymoney322 commented Jul 14, 2024

and a correct solution

IMO NSSM (as well as winsw) should be a workaround where an app can't be modified to run as a service.

The only correct solution (which would also decrease an ammount of third-party moving parts and would make an app self-contained) would be to use the system API itself. For C/C++ it would be winsvc.h. I made a quick search in google and it looks this is possible in golang too via func RegisterServiceCtrlHandlerEx
from "Windows" package.

Also, Im not sure if NSSM and WinSW release builds exist for an ARM architecture Windows deployments.

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

No branches or pull requests

3 participants