Skip to content

Commit 10dd5c4

Browse files
author
Ethan Hann
committed
Support installing as service
1 parent 9f332b4 commit 10dd5c4

File tree

4 files changed

+121
-47
lines changed

4 files changed

+121
-47
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System.ComponentModel;
2+
using System.Configuration.Install;
3+
using System.ServiceProcess;
4+
5+
6+
namespace IntegrationEngine.ConsoleHost
7+
{
8+
[RunInstaller(true)]
9+
public class InEngineServerInstaller : Installer
10+
{
11+
public InEngineServerInstaller()
12+
{
13+
var serviceProcessInstaller = new ServiceProcessInstaller();
14+
serviceProcessInstaller.Account = ServiceAccount.LocalSystem;
15+
serviceProcessInstaller.Username = null;
16+
serviceProcessInstaller.Password = null;
17+
Installers.Add(serviceProcessInstaller);
18+
19+
var serviceInstaller = new ServiceInstaller();
20+
serviceInstaller.DisplayName = "InEngine.NET Server";
21+
serviceInstaller.StartType = ServiceStartMode.Automatic;
22+
serviceInstaller.ServiceName = Program.ServiceName;
23+
Installers.Add(serviceInstaller);
24+
}
25+
}
26+
}

IntegrationEngine.ConsoleHost/IntegrationEngine.ConsoleHost.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,16 @@
6464
<Reference Include="RazorEngine">
6565
<HintPath>..\packages\RazorEngine.3.5.0\lib\net45\RazorEngine.dll</HintPath>
6666
</Reference>
67+
<Reference Include="System.Configuration.Install" />
68+
<Reference Include="System.ServiceProcess" />
6769
<Reference Include="System.Web.Razor">
6870
<HintPath>..\packages\Microsoft.AspNet.Razor.3.2.2\lib\net45\System.Web.Razor.dll</HintPath>
6971
</Reference>
7072
</ItemGroup>
7173
<ItemGroup>
74+
<Compile Include="InEngineServerInstaller.cs">
75+
<SubType>Component</SubType>
76+
</Compile>
7277
<Compile Include="IntegrationJobs\SampleSqlReport\SampleReport.cs" />
7378
<Compile Include="IntegrationJobs\SampleSqlReport\SampleDatum.cs" />
7479
<Compile Include="IntegrationJobs\SampleSqlReport\SampleSqlReportJob.cs" />
Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,58 @@
11
using System;
2+
using System.IO;
23
using System.Reflection;
4+
using System.ServiceProcess;
35

46
namespace IntegrationEngine.ConsoleHost
57
{
6-
public class MainClass
8+
public class Program
79
{
10+
public const string ServiceName = "InEngine.NET Server";
11+
public static EngineHost EngineHosts { get; set; }
812
public static void Main(string[] args)
913
{
10-
(new EngineHost(typeof(MainClass).Assembly)).Initialize();
14+
if (!Environment.UserInteractive)
15+
{
16+
// Set current working directory as services use the system directory by default.
17+
Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
18+
using (var service = new Service())
19+
ServiceBase.Run(service);
20+
}
21+
else
22+
{
23+
Start(args);
24+
Console.WriteLine("Press any key to stop...");
25+
Console.ReadKey(true);
26+
Stop();
27+
}
28+
}
29+
30+
31+
private static void Start(string[] args)
32+
{
33+
EngineHosts = new EngineHost(typeof(Program).Assembly);
34+
EngineHosts.Initialize();
35+
}
36+
37+
private static void Stop()
38+
{}
39+
40+
public class Service : ServiceBase
41+
{
42+
public Service()
43+
{
44+
ServiceName = Program.ServiceName;
45+
}
46+
47+
protected override void OnStart(string[] args)
48+
{
49+
Program.Start(args);
50+
}
51+
52+
protected override void OnStop()
53+
{
54+
Program.Stop();
55+
}
1156
}
1257
}
1358
}

IntegrationEngine.sln

Lines changed: 43 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 2012
3+
# Visual Studio 2013
44
VisualStudioVersion = 12.0.31101.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntegrationEngine", "IntegrationEngine\IntegrationEngine.csproj", "{7D49353D-A68C-4ACA-A6A5-40B1C314C30E}"
@@ -49,36 +49,6 @@ Global
4949
Release|x86 = Release|x86
5050
EndGlobalSection
5151
GlobalSection(ProjectConfigurationPlatforms) = postSolution
52-
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
53-
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
54-
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
55-
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
56-
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Debug|x86.ActiveCfg = Debug|Any CPU
57-
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
58-
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Release|Any CPU.Build.0 = Release|Any CPU
59-
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
60-
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Release|Mixed Platforms.Build.0 = Release|Any CPU
61-
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Release|x86.ActiveCfg = Release|Any CPU
62-
{3F3794D7-4078-4D26-954C-7864173EDD86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
63-
{3F3794D7-4078-4D26-954C-7864173EDD86}.Debug|Any CPU.Build.0 = Debug|Any CPU
64-
{3F3794D7-4078-4D26-954C-7864173EDD86}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
65-
{3F3794D7-4078-4D26-954C-7864173EDD86}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
66-
{3F3794D7-4078-4D26-954C-7864173EDD86}.Debug|x86.ActiveCfg = Debug|Any CPU
67-
{3F3794D7-4078-4D26-954C-7864173EDD86}.Release|Any CPU.ActiveCfg = Release|Any CPU
68-
{3F3794D7-4078-4D26-954C-7864173EDD86}.Release|Any CPU.Build.0 = Release|Any CPU
69-
{3F3794D7-4078-4D26-954C-7864173EDD86}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
70-
{3F3794D7-4078-4D26-954C-7864173EDD86}.Release|Mixed Platforms.Build.0 = Release|Any CPU
71-
{3F3794D7-4078-4D26-954C-7864173EDD86}.Release|x86.ActiveCfg = Release|Any CPU
72-
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
73-
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Debug|Any CPU.Build.0 = Debug|Any CPU
74-
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
75-
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
76-
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Debug|x86.ActiveCfg = Debug|Any CPU
77-
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Release|Any CPU.ActiveCfg = Release|Any CPU
78-
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Release|Any CPU.Build.0 = Release|Any CPU
79-
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
80-
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
81-
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Release|x86.ActiveCfg = Release|Any CPU
8252
{7D49353D-A68C-4ACA-A6A5-40B1C314C30E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
8353
{7D49353D-A68C-4ACA-A6A5-40B1C314C30E}.Debug|Any CPU.Build.0 = Debug|Any CPU
8454
{7D49353D-A68C-4ACA-A6A5-40B1C314C30E}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
@@ -90,16 +60,6 @@ Global
9060
{7D49353D-A68C-4ACA-A6A5-40B1C314C30E}.Release|Mixed Platforms.Build.0 = Release|x86
9161
{7D49353D-A68C-4ACA-A6A5-40B1C314C30E}.Release|x86.ActiveCfg = Release|x86
9262
{7D49353D-A68C-4ACA-A6A5-40B1C314C30E}.Release|x86.Build.0 = Release|x86
93-
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
94-
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
95-
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
96-
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
97-
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Debug|x86.ActiveCfg = Debug|Any CPU
98-
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
99-
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Release|Any CPU.Build.0 = Release|Any CPU
100-
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
101-
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
102-
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Release|x86.ActiveCfg = Release|Any CPU
10363
{C273AE91-E13F-4443-8D01-9C97016AB4AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
10464
{C273AE91-E13F-4443-8D01-9C97016AB4AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
10565
{C273AE91-E13F-4443-8D01-9C97016AB4AC}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
@@ -111,6 +71,26 @@ Global
11171
{C273AE91-E13F-4443-8D01-9C97016AB4AC}.Release|Mixed Platforms.Build.0 = Release|x86
11272
{C273AE91-E13F-4443-8D01-9C97016AB4AC}.Release|x86.ActiveCfg = Release|x86
11373
{C273AE91-E13F-4443-8D01-9C97016AB4AC}.Release|x86.Build.0 = Release|x86
74+
{3F3794D7-4078-4D26-954C-7864173EDD86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
75+
{3F3794D7-4078-4D26-954C-7864173EDD86}.Debug|Any CPU.Build.0 = Debug|Any CPU
76+
{3F3794D7-4078-4D26-954C-7864173EDD86}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
77+
{3F3794D7-4078-4D26-954C-7864173EDD86}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
78+
{3F3794D7-4078-4D26-954C-7864173EDD86}.Debug|x86.ActiveCfg = Debug|Any CPU
79+
{3F3794D7-4078-4D26-954C-7864173EDD86}.Release|Any CPU.ActiveCfg = Release|Any CPU
80+
{3F3794D7-4078-4D26-954C-7864173EDD86}.Release|Any CPU.Build.0 = Release|Any CPU
81+
{3F3794D7-4078-4D26-954C-7864173EDD86}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
82+
{3F3794D7-4078-4D26-954C-7864173EDD86}.Release|Mixed Platforms.Build.0 = Release|Any CPU
83+
{3F3794D7-4078-4D26-954C-7864173EDD86}.Release|x86.ActiveCfg = Release|Any CPU
84+
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
85+
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
86+
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
87+
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
88+
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Debug|x86.ActiveCfg = Debug|Any CPU
89+
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
90+
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Release|Any CPU.Build.0 = Release|Any CPU
91+
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
92+
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Release|Mixed Platforms.Build.0 = Release|Any CPU
93+
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Release|x86.ActiveCfg = Release|Any CPU
11494
{DFCD19CE-A96A-4B19-8CF1-9CAC560E7F42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
11595
{DFCD19CE-A96A-4B19-8CF1-9CAC560E7F42}.Debug|Any CPU.Build.0 = Debug|Any CPU
11696
{DFCD19CE-A96A-4B19-8CF1-9CAC560E7F42}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@@ -143,6 +123,26 @@ Global
143123
{F3FCB706-F0DD-46C1-B121-785757FAE9B9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
144124
{F3FCB706-F0DD-46C1-B121-785757FAE9B9}.Release|x86.ActiveCfg = Release|Any CPU
145125
{F3FCB706-F0DD-46C1-B121-785757FAE9B9}.Release|x86.Build.0 = Release|Any CPU
126+
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
127+
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
128+
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
129+
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
130+
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Debug|x86.ActiveCfg = Debug|Any CPU
131+
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
132+
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Release|Any CPU.Build.0 = Release|Any CPU
133+
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
134+
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
135+
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Release|x86.ActiveCfg = Release|Any CPU
136+
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
137+
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Debug|Any CPU.Build.0 = Debug|Any CPU
138+
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
139+
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
140+
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Debug|x86.ActiveCfg = Debug|Any CPU
141+
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Release|Any CPU.ActiveCfg = Release|Any CPU
142+
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Release|Any CPU.Build.0 = Release|Any CPU
143+
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
144+
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
145+
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Release|x86.ActiveCfg = Release|Any CPU
146146
{F999051E-B715-4AB9-A3B2-0D91A896A2C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
147147
{F999051E-B715-4AB9-A3B2-0D91A896A2C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
148148
{F999051E-B715-4AB9-A3B2-0D91A896A2C2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@@ -154,12 +154,10 @@ Global
154154
{F999051E-B715-4AB9-A3B2-0D91A896A2C2}.Release|Mixed Platforms.Build.0 = Release|Any CPU
155155
{F999051E-B715-4AB9-A3B2-0D91A896A2C2}.Release|x86.ActiveCfg = Release|Any CPU
156156
EndGlobalSection
157-
GlobalSection(NestedProjects) = preSolution
157+
GlobalSection(SolutionProperties) = preSolution
158+
HideSolutionNode = FALSE
158159
EndGlobalSection
159160
GlobalSection(MonoDevelopProperties) = preSolution
160161
StartupItem = IntegrationEngine.ConsoleHost\IntegrationEngine.ConsoleHost.csproj
161162
EndGlobalSection
162-
GlobalSection(SolutionProperties) = preSolution
163-
HideSolutionNode = FALSE
164-
EndGlobalSection
165163
EndGlobal

0 commit comments

Comments
 (0)