mirror of
https://github.com/CommonLoon102/NBloodServerSupervisor.git
synced 2024-12-22 18:52:44 +01:00
no need for nblood exe path
This commit is contained in:
parent
6b1351ab0d
commit
9f696fdd7f
@ -8,14 +8,11 @@ namespace Supervisor
|
||||
{
|
||||
public static readonly State State = new State();
|
||||
|
||||
public static void Main(string[] args)
|
||||
public static void Main()
|
||||
{
|
||||
NBloodServerListener.StartListening();
|
||||
WebApiListener.StartListening();
|
||||
|
||||
if (args.Length > 0)
|
||||
PublicServerManager.Start(args[0]);
|
||||
|
||||
PublicServerManager.Start();
|
||||
PrivateServerManager.Start();
|
||||
|
||||
while (true)
|
||||
|
@ -1,10 +1,9 @@
|
||||
using Common;
|
||||
using Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -12,7 +11,7 @@ namespace Supervisor
|
||||
{
|
||||
class PublicServerManager
|
||||
{
|
||||
public static void Start(string nbloodPath)
|
||||
public static void Start()
|
||||
{
|
||||
Thread.Sleep(TimeSpan.FromSeconds(2));
|
||||
KillOrphanedServers();
|
||||
@ -20,7 +19,7 @@ namespace Supervisor
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
LaunchNewServersWhenNeeded(nbloodPath);
|
||||
LaunchNewServersWhenNeeded();
|
||||
Thread.Sleep(TimeSpan.FromSeconds(1));
|
||||
}
|
||||
});
|
||||
@ -37,7 +36,7 @@ namespace Supervisor
|
||||
}
|
||||
}
|
||||
|
||||
private static void LaunchNewServersWhenNeeded(string nbloodPath)
|
||||
private static void LaunchNewServersWhenNeeded()
|
||||
{
|
||||
const int maxPlayers = 8;
|
||||
|
||||
@ -46,7 +45,11 @@ namespace Supervisor
|
||||
if (IsNewServerNeeded(i))
|
||||
{
|
||||
int port = PortUtils.GetPort();
|
||||
var process = Process.Start(nbloodPath, $"-server {i} -port {port}");
|
||||
string nbloodServer = "nblood_server";
|
||||
bool isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
||||
if (isWindows)
|
||||
nbloodServer += ".exe";
|
||||
var process = Process.Start(nbloodServer, $"-server {i} -port {port}");
|
||||
Program.State.Servers.AddOrUpdate(port, new Server()
|
||||
{
|
||||
Port = port,
|
||||
|
@ -1,17 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace WebInterface
|
||||
{
|
||||
@ -25,16 +20,13 @@ namespace WebInterface
|
||||
|
||||
private void StartSupervisor()
|
||||
{
|
||||
string nbloodPath = Configuration.GetValue<string>("NBloodPath");
|
||||
bool isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
||||
string supervisor = "Supervisor";
|
||||
if (isWindows)
|
||||
supervisor += ".exe";
|
||||
if (!File.Exists(nbloodPath))
|
||||
throw new Exception($"Couldn't find nblood_server at {nbloodPath}");
|
||||
if (!File.Exists(supervisor))
|
||||
throw new Exception($"Couldn't find {supervisor} in {Directory.GetCurrentDirectory()}");
|
||||
Process.Start(supervisor, nbloodPath);
|
||||
Process.Start(supervisor);
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
@ -8,6 +8,5 @@
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"MaximumServers": 20,
|
||||
"NBloodPath": "\\path\\to\\nblood_server",
|
||||
"ApiKey": "!!! CHANGE ME !!!"
|
||||
"ApiKey": "CHANGEME"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user