Skip to content

Commit

Permalink
Change log level for service actions
Browse files Browse the repository at this point in the history
  • Loading branch information
zimbres committed Aug 5, 2024
1 parent c04ab0a commit b9858c7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/ServiceMonitor/ServiceMonitor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<UserSecretsId>dotnet-ServiceMonitor-02b8361b-7a93-472d-a2d6-7b2e8f7973af</UserSecretsId>
<AssemblyVersion>$(PackageVersion)</AssemblyVersion>
<FileVersion>$(PackageVersion)</FileVersion>
<Version>2.0.0.1</Version>
<Version>2.0.0.2</Version>
<ApplicationIcon>service.ico</ApplicationIcon>
<Copyright>Zimbres.COM</Copyright>
</PropertyGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/ServiceMonitor/Services/ControlService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ public void RestartService(string serviceName)
using var serviceController = new ServiceController(serviceName);
if (serviceController.Status == ServiceControllerStatus.Stopped)
{
_logger.LogInformation("Starting service {serviceName}...", serviceName);
_logger.LogWarning("Starting service {serviceName}...", serviceName);
serviceController.Start();
}

else if (serviceController.Status == ServiceControllerStatus.Running)
{
_logger.LogInformation("Restarting service {serviceName}...", serviceName);
_logger.LogWarning("Restarting service {serviceName}...", serviceName);
serviceController.Stop();
serviceController.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(60));
serviceController.Start();
}

if (serviceController.Status == ServiceControllerStatus.StopPending)
{
_logger.LogInformation("Waiting service {serviceName} to stop...", serviceName);
_logger.LogWarning("Waiting service {serviceName} to stop...", serviceName);
serviceController.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(60));
_logger.LogInformation("Starting service {serviceName}...", serviceName);
_logger.LogWarning("Starting service {serviceName}...", serviceName);
serviceController.Start();
}
serviceController.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(60));
Expand Down

0 comments on commit b9858c7

Please sign in to comment.