-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
31 lines (26 loc) · 858 Bytes
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System.Runtime.InteropServices;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Celestial;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// hide the command window that is shown when the worker is running
// ideally this app would run as a Windows Service, but user services aren't a thing on Windows apparently
WindowsCrap.HideWindow();
}
IHostBuilder builder = Host.CreateDefaultBuilder(args)
.ConfigureServices(services =>
{
services.AddHostedService<Worker>();
services.AddProviders();
});
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
builder.UseSystemd();
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
builder.UseWindowsService();
}
IHost host = builder.Build();
host.Run();