-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathService.cs
More file actions
55 lines (48 loc) · 1.28 KB
/
Service.cs
File metadata and controls
55 lines (48 loc) · 1.28 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
using System;
using System.ServiceProcess;
using ServiceStack.Configuration;
using Backbone.Todos;
namespace Service
{
partial class Service : ServiceBase
{
private ToDoAppHost appHost;
public Service()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
appHost = new ToDoAppHost();
appHost.Init();
var appSettings = new AppSettings();
var url = appSettings.GetString("Api.Url");
Console.WriteLine("Listening: " + url);
appHost.Start(url);
}
protected override void OnStop()
{
Console.WriteLine("Stopping...");
appHost.Stop();
appHost.Dispose();
Console.WriteLine("Stopped");
}
public static void Main(string[] args)
{
var service = new Service();
#if !__MonoCS__
if (Environment.UserInteractive)
#else
if (AppDomain.CurrentDomain.FriendlyName != "service")
#endif
{
service.OnStart(args);
Console.WriteLine("Press any key to stop program");
Console.Read();
service.OnStop();
}
else
Run(service);
}
}
}