My New Year's resolution is to stop making commits like these
This commit is contained in:
61
Torch.Server/TorchServiceInstaller.cs
Normal file
61
Torch.Server/TorchServiceInstaller.cs
Normal file
@@ -0,0 +1,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)]
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user