v0.18.4: Critical Failure when Starting as Windows Service (Service Start Failed) #847
Replies: 5 comments
-
|
Hey @felixxarcom, I'll have a look today and get back to you with some suggestions. 👍 |
Beta Was this translation helpful? Give feedback.
-
|
Hey @felixxarcom, so far I couldn't reproduce the issue on my available Windows machine. The following script (which is based on yours) works fine, the server is up and running: The OS is On my end, I'll try to get a Windows Server 2019 evaluation copy to test it there. |
Beta Was this translation helpful? Give feedback.
-
|
@felixxarcom, I've tested
I currently assume that it might be something with the permissions on your end, what do you think? Also, the I'm happy to assist you, but so far I'd need more context or details from your side. |
Beta Was this translation helpful? Give feedback.
-
|
Hi burningalchemist Title: Appreciation & Detailed Findings regarding v0.18.4 behavior as a Windows Service Description: First of all, we want to express our sincere gratitude for your work on this exporter. It is a fantastic tool that solves a critical need for us, and we really appreciate your effort in maintaining it. We are writing this not to report that the software "doesn't work"—because the core logic is excellent—but to share a detailed timeline of specific behaviors we observed when deploying v0.18.4 on Windows Server 2019/2022. We hope these findings can help you refine the Windows integration in future releases. Here is the forensic timeline of our deployment attempt:
This leads us to believe that the binary is working fine, but it might be missing the native Windows Service wrapper implementation (likely golang.org/x/sys/windows/svc) required to handshake with the SCM. As a result, Windows thinks it failed and tries to kill it, but the process persists.
Conclusion Thank you again for this project. We believe that adding the native Windows Service entry point code would resolve these deployment issues entirely, as the exporter logic itself is performing perfectly. |
Beta Was this translation helpful? Give feedback.
-
|
Hey @felixxarcom, I appreciate the AI-generated response here, however it doesn't bring much clarity to help me resolve the issue.
As an alternative, I'd suggest to check out NSSM or WinSW. That might help. Otherwise, there is nothing for me to fix or implement without any additional context or details to reproduce the issue. Since I can't confirm it's a bug, I'll move the ticket to |
Beta Was this translation helpful? Give feedback.


Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
Attempting to register and start sql_exporter.exe (v0.18.4) as a Windows Service fails consistently with an operating system error (StartServiceFailed and sometimes the low-level ERROR 487), even when using the technically correct binPath syntax. The binary is unable to maintain execution in the Windows Service Control Manager (SCM) environment, leading to an immediate crash upon attempting to start. This suggests a Go binary/Windows API incompatibility rather than a configuration error.
To Reproduce
This bug occurs when attempting to load any configuration file via the Windows Service layer:
System: Windows Server (reproducible on various versions, tested on 2019/2022).
Files: Use the sql_exporter.exe binary (Version 0.18.4) and a valid config.yml.
Command: Attempt to create and start the service using the correct New-Service or sc.exe syntax:
PowerShell
$BinPath = "C:\ruta\sql_exporter.exe"
$CfgPath = "C:\ruta\config.yml"
$FullCommand = ('"{0}" --config.file="{1}"' -f $BinPath, $CfgPath)
Attempt to create using native utility
sc.exe create sql_exporter_test binPath= "$FullCommand" start= auto DisplayName= "Prometheus SQL Exporter Test"
Start-Service sql_exporter_test
Error Seen (PowerShell): Start-Service : No pudo iniciarse el servicio... (ServiceCommandException: StartServiceFailed).
Error Seen (SCM): The low-level utility sc.exe create often fails with ERROR 487: Se ha intentado tener acceso a una dirección no válida, indicating a conflict during the registration process itself.
Expected behavior
The service should register successfully and transition to a Running state, listening on its configured port (e.g., 9399), as it does when executed manually in the foreground.
Configuration
Exporter Version: 0.18.4.
OS: Windows Server.
Environment: Executed as NT AUTHORITY\SYSTEM (via SCM).
Additional context
Functional Mode: The binary works perfectly when executed manually in the console (.\sql_exporter.exe --config.file="config.yml"). This confirms the configuration file is valid.
Workaround: The only stable way to run this version in the background is by registering the command via Windows Task Scheduler (schtasks), not via New-Service or sc.exe, confirming a failure in the service control integration.
Beta Was this translation helpful? Give feedback.
All reactions