Skip to content

Commit c950dda

Browse files
Configure windows services to keep trying to restart (#4874)
1 parent ce1400c commit c950dda

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/ServiceControlInstaller.Engine/Services/ServiceRecoveryHelper.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ public static void SetRecoveryOptions(string serviceName)
8080

8181
void SetRestartOnFailure(string serviceName)
8282
{
83-
const int actionCount = 2;
84-
const uint delay = 60000;
83+
const int actionCount = 3;
8584

8685
var service = IntPtr.Zero;
8786
var failureActionsPtr = IntPtr.Zero;
@@ -95,18 +94,27 @@ void SetRestartOnFailure(string serviceName)
9594
var action1 = new SC_ACTION
9695
{
9796
Type = SC_ACTION_TYPE.SC_ACTION_RESTART,
98-
Delay = delay
97+
Delay = 10000
9998
};
10099

101100
Marshal.StructureToPtr(action1, actionPtr, false);
102101

103102
var action2 = new SC_ACTION
104103
{
105-
Type = SC_ACTION_TYPE.SC_ACTION_NONE,
106-
Delay = delay
104+
Type = SC_ACTION_TYPE.SC_ACTION_RESTART,
105+
Delay = 30000
107106
};
107+
108108
Marshal.StructureToPtr(action2, (IntPtr)((long)actionPtr + Marshal.SizeOf(typeof(SC_ACTION))), false);
109109

110+
var action3 = new SC_ACTION
111+
{
112+
Type = SC_ACTION_TYPE.SC_ACTION_RESTART,
113+
Delay = 60000
114+
};
115+
116+
Marshal.StructureToPtr(action3, (IntPtr)((long)actionPtr + (Marshal.SizeOf(typeof(SC_ACTION)) * 2)), false);
117+
110118
var failureActions = new SERVICE_FAILURE_ACTIONS
111119
{
112120
dwResetPeriod = 0,

0 commit comments

Comments
 (0)