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

Run as Windows service is failing #141

Open
oblivian opened this issue Feb 17, 2024 · 6 comments
Open

Run as Windows service is failing #141

oblivian opened this issue Feb 17, 2024 · 6 comments

Comments

@oblivian
Copy link

Describe the bug
Failing when running as a Windows Service
Runs fine when ran from CLI.

To Reproduce

sc create nvidia_gpu_exporter binpath= "C:\Program Files\SysAdm\nvidia_gpu_exporter.exe"
sc start nvidia_gpu_exporter

Produces:

[SC] StartService FAILED 1053:
The service did not respond to the start or control request in a timely fashion.

Expected behavior
I was expecting it to work like most other "exporters" like windows_exporter where one simply use the above procedure.
I see nssm.exe is recommended, but it is long since abandon-ware and too many anti-viruses flag it as malicious to be trusted anymore.

Console output

[SC] StartService FAILED 1053:
The service did not respond to the start or control request in a timely fashion.

Model and Version

  • GPU Model: GeForce RTX 2080
  • App version and architecture: v1.2.0 - Win_x86_64
  • Installation method: binary download
  • Operating System: Windows 10
  • Nvidia GPU driver version: Windows Game Ready Driver 551.23
@lZzozZl
Copy link

lZzozZl commented Mar 22, 2024

I have same problem too.
I would like to use SC to install and run the service

@endresjo
Copy link

endresjo commented Nov 21, 2024

I first tried the same for not having to use the NSSM. The Problem with SC is that the nvidia_gpu_exporter.exe is not a "true" Windows service application (it does not implement the Windows Services API.

Now I'm using a scheduled task to start the exporter after Windows startup with:

## ensure C:\it\nvidia_gpu_exporter.exe exists
$Trigger = New-ScheduledTaskTrigger -AtStartup
$Action = New-ScheduledTaskAction -Execute "C:\it\nvidia_gpu_exporter.exe"
$Principal = New-ScheduledTaskPrincipal -GroupId "NT AUTHORITY\LocalService"
Register-ScheduledTask -TaskName "nvidia_gpu_exporter" -Trigger $Trigger -Action $Action -Principal $Principal

@alexwbaule
Copy link

alexwbaule commented Dec 4, 2024

Hi everyone...

@utkuozdemir @endresjo @lZzozZl @oblivian i create a fork, and use the "kardianos" go package, that is a "wrapper" to windows SVC and anothers "service" implemantations (mac, windows, linux, etc).

I just "copy and paste" some code from another project that i use to work as "windows service".

Im testing it, and its work as windows service , without use of nssm.

If someone has interest, is in my master fork branch https://github.com/alexwbaule/nvidia_gpu_exporter (you can look the modifications at cmd/nvidia_gpu_exporter/main.go).

If its ok, i can do a PR to merge it... (if someone test it too).

To test, just build as usual.

for my, i cross compile from my linux:
GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o nvidia_gpu_exporter.exe cmd/nvidia_gpu_exporter/main.go

@utkuozdemir
Copy link
Owner

utkuozdemir commented Dec 4, 2024

@alexwbaule Thanks, this is something I wanted to do since a long time. Feel free to open the PR, but I cannot promise going over it anytime soon. I think it might get a bit tricky with the logger etc, so I would like to iterate on it myself before merging it too quickly. So, the PR is welcome, but it might take a long time till I get to it and eventually merge. In the meanwhile I suggest using your fork.

@alexwbaule
Copy link

@utkuozdemir it's Ok for me...

I will do a PR , and we can test it, discuss, etc..

Tonight, when I come home I will do it.

@utkuozdemir
Copy link
Owner

@utkuozdemir it's Ok for me...

I will do a PR , and we can test it, discuss, etc..

Tonight, when I come home I will do it.

No rush pls :)

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

5 participants