Closed ka4ep closed 6 years ago
That has been implemented in https://github.com/dasMulli/dotnet-win32-service/pull/36
var serviceDefinition = new ServiceDefinitionBuilder(ServiceName)
.WithDisplayName(ServiceDisplayName)
.WithDescription(ServiceDescription)
.WithBinaryPath(fullServiceCommand)
.WithCredentials(Win32ServiceCredentials.LocalSystem)
.WithAutoStart(true)
.WithFailureActions(new ServiceFailureActions(TimeSpan.FromDays(1), null, null, new[]{
new ScAction
{
Delay = TimeSpan.FromMinutes(5),
Type = ScActionType.ScActionRestart
},
new ScAction
{
Delay = TimeSpan.FromMinutes(5),
Type = ScActionType.ScActionRestart
},
new ScAction
{
Delay = TimeSpan.FromMinutes(5),
Type = ScActionType.ScActionRestart
}
}))
.Build();
new Win32ServiceManager().CreateOrUpdateService(serviceDefinition, startImmediately: true);
I really need to upgrade and use as package. My copy's missing that bit. Thanks a lot for this example!
I'm using some 1-2 years old copied versions of this win32 service and Peter Kottas' wrapper for an ordinary .NET 4.7 project. Due to use of some 3rd party legacy API I have a demand to programmatically restart service occasionally to release that API's unmanaged resources. Old bugger leaks memory and handles. So, somewhere deep in code this block
initializes a stops service. The only thing lacks for a proper restart are the following options: Not the end of the world, but local admin may forget to set these up manually after update. As I haven't sync'd this project with my copy for a while, are these options already implemented? If not, are there plans for these properties' implementation?