Skip to content

Commit

Permalink
Update ConsoleRunHost.cs
Browse files Browse the repository at this point in the history
Used linux support using .RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows) on netstarndard
  • Loading branch information
Chris Gilligan authored and phatboyg committed May 13, 2019
1 parent 8114798 commit 607ed2a
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/Topshelf/Hosts/ConsoleRunHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,24 @@ public TopshelfExitCode Run()

AppDomain.CurrentDomain.UnhandledException += CatchUnhandledException;

if (_environment.IsServiceInstalled(_settings.ServiceName))
#if NETCORE
if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows))
{
if (!_environment.IsServiceStopped(_settings.ServiceName))
#endif
if (_environment.IsServiceInstalled(_settings.ServiceName))
{
_log.ErrorFormat("The {0} service is running and must be stopped before running via the console",
_settings.ServiceName);

return TopshelfExitCode.ServiceAlreadyRunning;
if (!_environment.IsServiceStopped(_settings.ServiceName))
{
_log.ErrorFormat(
"The {0} service is running and must be stopped before running via the console",
_settings.ServiceName);

return TopshelfExitCode.ServiceAlreadyRunning;
}
}
#if NETCORE
}
#endif

bool started = false;
try
Expand Down

0 comments on commit 607ed2a

Please sign in to comment.