Plugin system working, Windows service and command system in progress

This commit is contained in:
John Gross
2017-01-05 02:49:43 -08:00
parent e0a4ee9ce0
commit 4949982fa8
24 changed files with 352 additions and 132 deletions

View File

@@ -3,12 +3,14 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.ServiceProcess;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
using NLog;
using Torch;
using Torch.API;
@@ -17,6 +19,7 @@ namespace Torch.Server
public static class Program
{
private static ITorchServer _server;
private static Logger _log = LogManager.GetLogger("Torch");
public static void Main(string[] args)
{
@@ -29,6 +32,39 @@ namespace Torch.Server
return;
}
if (args.FirstOrDefault() == "-svcinstall")
{
var runArgs = string.Join(" ", args.Skip(1));
_log.Info($"Installing Torch as a service with arguments '{runArgs}'");
var startInfo = new ProcessStartInfo
{
FileName = "sc.exe",
Arguments = $"create Torch binPath=\"{Assembly.GetExecutingAssembly().Location} {runArgs}\"",
CreateNoWindow = true,
UseShellExecute = true,
Verb = "runas"
};
Process.Start(startInfo).WaitForExit();
_log.Info("Torch service installed");
return;
}
if (args.FirstOrDefault() == "-svcuninstall")
{
_log.Info("Uninstalling Torch service");
var startInfo = new ProcessStartInfo
{
FileName = "sc.exe",
Arguments = "delete Torch",
CreateNoWindow = true,
UseShellExecute = true,
Verb = "runas"
};
Process.Start(startInfo).WaitForExit();
_log.Info("Torch service uninstalled");
return;
}
_server = new TorchServer();
_server.Init();
_server.Start();