ricoberger / script_exporter

Prometheus exporter to execute scripts and collect metrics from the output or the exit status.
MIT License
354 stars 82 forks source link

Fix the way to detect if running as Windows service #73

Closed masshash closed 1 year ago

masshash commented 1 year ago

The function https://pkg.go.dev/golang.org/x/sys/windows/svc#IsAnInteractiveSession is deprecated because the way to detect if it's a service or not is not reliable. So I fixed to use IsWindowsService instead of IsAnInteractiveSession.

With this change, if you wrap your service with NSSM (or WinSW), script_exporter will now be correctly detected as a non-service and will be able to start as wrapped service. Fixes #47

ricoberger commented 1 year ago

Hi @masshash thanks for the fix 🙂

masshash commented 1 year ago

@ricoberger thanks for the quick merge and release!