You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Zero/ZeroLevel.Discovery/Program.cs

38 lines
1.1 KiB

using System;
using Topshelf;
using static ZeroLevel.Bootstrap;
namespace ZeroLevel.Discovery
{
internal static class Program
{
private static void Main(string[] args)
{
IServiceExecution se = null;
HostFactory.Run(x =>
{
x.StartAutomatically();
x.Service<BootstrapFluent>(s =>
{
s.ConstructUsing(name => Bootstrap.Startup<DiscoveryService>(args));
s.WhenStopped(tc => { tc.Stop(); Bootstrap.Shutdown(); });
s.WhenStarted(tc => { se = tc.Run(); });
});
x.RunAsLocalSystem();
x.SetDescription("Discovery");
x.SetDisplayName("Discovery");
x.SetServiceName("Discovery");
x.OnException(ex =>
{
Log.Error(ex, "Service exception");
});
});
if (Environment.UserInteractive && args?.Length < 1)
{
se?.WaitWhileStatus(ZeroServiceStatus.Running);
}
}
}
}

Powered by TurnKey Linux.