-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
52 lines (41 loc) · 1.44 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using QuickStart.Dotnet;
using LittleHorse.Sdk;
using LittleHorse.Sdk.Worker;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.DependencyInjection;
public class Program
{
private static ServiceProvider? _serviceProvider;
private static void SetupApplication()
{
_serviceProvider = new ServiceCollection()
.AddLogging(config =>
{
config.AddConsole();
config.SetMinimumLevel(LogLevel.Debug);
})
.BuildServiceProvider();
}
private static LHConfig GetLHConfig(ILoggerFactory loggerFactory)
{
var config = new LHConfig(loggerFactory);
string filePath = Path.Combine(Directory.GetCurrentDirectory(), ".config/littlehorse.config");
if (File.Exists(filePath))
config = new LHConfig(filePath, loggerFactory);
return config;
}
static void Main(string[] args)
{
SetupApplication();
if (_serviceProvider != null)
{
var loggerFactory = _serviceProvider.GetRequiredService<ILoggerFactory>();
var config = GetLHConfig(loggerFactory);
GreetWorker executableGreet = new GreetWorker();
var taskWorker = new LHTaskWorker<GreetWorker>(executableGreet, "greet", config);
taskWorker.RegisterTaskDef();
Thread.Sleep(1000);
taskWorker.Start();
}
}
}