Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
59 lines (52 loc) · 1.4 KB
/
Copy pathProgram.cs
File metadata and controls
59 lines (52 loc) · 1.4 KB
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
53
54
55
56
57
58
59
//------------------------------------------------------------------------------
// <copyright company="LeanKit Inc.">
// Copyright (c) LeanKit Inc. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Linq;
using ServiceStack.Text;
using Topshelf;
namespace IntegrationService
{
public class Program
{
public static void Main(string[] args)
{
var runOnce = args.Any( arg => arg.Equals("-runonce", StringComparison.OrdinalIgnoreCase));
if (!runOnce)
{
HostFactory.Run(x =>
{
var configOnly = false;
x.AddCommandLineDefinition("config", p => configOnly = true);
x.Service<IntegrationService>(s =>
{
s.ConstructUsing(name => new IntegrationService());
s.WhenStarted((service, host) =>
{
if (configOnly)
{
service.StartConfigService();
return true;
}
return service.Start(host);
});
s.WhenStopped((tc, host) => tc.Stop(host));
});
x.RunAsLocalSystem();
x.EnableShutdown();
x.SetDescription("LeanKit Integration Service");
x.SetDisplayName("LeanKit Integration Service");
x.SetServiceName("LeanKit-Integration-Service");
});
}
else
{
"Manually running the integration once...".Print();
var service = new IntegrationService();
service.Start(true);
}
}
}
}