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
x/sys/windows/svc/mgr: add Service.RecoveryActionsOnNonCrashFailures and Service.SetRecoveryActionsOnNonCrashFailures #59016
Comments
I am able to work around this by calling windows.ChangeServiceConfig2() directly: import (
"github.com/winlabs/gowin32/wrappers"
"golang.org/x/sys/windows"
"golang.org/x/sys/windows/svc"
"golang.org/x/sys/windows/svc/mgr"
)
...
flag := wrappers.SERVICE_FAILURE_ACTIONS_FLAG{
FailureActionsOnNonCrashFailures: 1,
}
err := windows.ChangeServiceConfig2(s.Handle, windows.SERVICE_CONFIG_FAILURE_ACTIONS_FLAG, (*byte)(unsafe.Pointer(&flag)))
... However, it seems like this should also be in the mgr package. |
Does this require changing the signature of cc @golang/windows |
You could do either of those. |
Hello @craig65535 If you want to have access to the failure actions flag, we can add 2 new methods similar to, for example:
Would that work for you? I did not need this functionality ever. But others contributed code for whatever service parameters they required. I doubt we could support all combinations that are supported by ChangeServiceConfig2 in a general and simple way. So I expect some users to call windows.ChangeServiceConfig2 directly. But it would be nice to have most common parameters supported. Alex |
@alexbrainman Yes, that sounds perfect. |
Would you like to try to add that code yourself? Alex |
Sure, I can give this one a shot as well. |
Change https://go.dev/cl/484896 mentions this issue: |
I propose to add these two methods
to the We already have similar Service.RebootMessage / Service.SetRebootMessage, Service.RecoveryActions / Service.SetRecoveryActions and few others. It is possible to achieve this functionality by calling Windows API directly. See #59016 (comment) for an example. But we decided since we already have similar attributes handled, maybe we can add Thank you for consideration. Alex |
Just want to make sure that this proposal is not forgotten. I labelled the issue as proposal about month ago. I hope I did not make mistake somewhere. Thank you for your help. Alex |
This proposal has been added to the active column of the proposals project |
Based on the discussion above, this proposal seems like a likely accept. |
No change in consensus, so accepted. 🎉 |
Proposal is at #59016 (comment)
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?windows/amd64
What did you do?
Created a Windows service that requires recovery actions (such as restarting) that are executed when the service has exited with an error but has not crashed.
With a *mgr.Service (
s
), I attempteds.SetRecoveryActions
and found that it did not support setting this flag.What did you expect to see?
s.SetRecoveryActions
should include the failure actions flag.This is supported by ChangeServiceConfig2 but not the wrapper that exists in Service.SetRecoveryActions.
What did you see instead?
s.SetRecoveryActions
can only set the recovery actions themselves, and the time at which each is active.Proposal details
See #59016 (comment) where we propose adding API to access
RecoveryActionsOnNonCrashFailures
flag.The text was updated successfully, but these errors were encountered: