-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathTorchServiceInstaller.cs
More file actions
61 lines (51 loc) · 1.75 KB
/
TorchServiceInstaller.cs
File metadata and controls
61 lines (51 loc) · 1.75 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
60
61
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
namespace Torch.Server
{
[RunInstaller(true)]
public class TorchServiceInstaller : Installer
{
private ServiceInstaller _serviceInstaller;
public TorchServiceInstaller()
{
var serviceProcessInstaller = new ServiceProcessInstaller();
_serviceInstaller = new ServiceInstaller();
serviceProcessInstaller.Account = ServiceAccount.LocalSystem;
serviceProcessInstaller.Username = null;
serviceProcessInstaller.Password = null;
_serviceInstaller.DisplayName = "Torch (SEDS)";
_serviceInstaller.Description = "Service for Torch (SE Dedicated Server)";
_serviceInstaller.StartType = ServiceStartMode.Manual;
_serviceInstaller.ServiceName = TorchService.Name;
Installers.Add(serviceProcessInstaller);
Installers.Add(_serviceInstaller);
}
/// <inheritdoc />
public override void Install(IDictionary stateSaver)
{
GetServiceName();
base.Install(stateSaver);
}
/// <inheritdoc />
public override void Uninstall(IDictionary savedState)
{
GetServiceName();
base.Uninstall(savedState);
}
private void GetServiceName()
{
var name = Context.Parameters["name"];
if (string.IsNullOrEmpty(name))
return;
_serviceInstaller.DisplayName = name;
_serviceInstaller.ServiceName = name;
}
}
}