Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ public static void SetRecoveryOptions(string serviceName)

void SetRestartOnFailure(string serviceName)
{
const int actionCount = 2;
const uint delay = 60000;
const int actionCount = 3;

var service = IntPtr.Zero;
var failureActionsPtr = IntPtr.Zero;
Expand All @@ -95,18 +94,27 @@ void SetRestartOnFailure(string serviceName)
var action1 = new SC_ACTION
{
Type = SC_ACTION_TYPE.SC_ACTION_RESTART,
Delay = delay
Delay = 10000
};

Marshal.StructureToPtr(action1, actionPtr, false);

var action2 = new SC_ACTION
{
Type = SC_ACTION_TYPE.SC_ACTION_NONE,
Delay = delay
Type = SC_ACTION_TYPE.SC_ACTION_RESTART,
Delay = 30000
};

Marshal.StructureToPtr(action2, (IntPtr)((long)actionPtr + Marshal.SizeOf(typeof(SC_ACTION))), false);

var action3 = new SC_ACTION
{
Type = SC_ACTION_TYPE.SC_ACTION_RESTART,
Delay = 60000
};

Marshal.StructureToPtr(action3, (IntPtr)((long)actionPtr + (Marshal.SizeOf(typeof(SC_ACTION)) * 2)), false);

var failureActions = new SERVICE_FAILURE_ACTIONS
{
dwResetPeriod = 0,
Expand Down