mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-06 20:08:40 +00:00
parent
dde6b38ea5
commit
6a222664d7
4 changed files with 8 additions and 40 deletions
|
@ -11,7 +11,6 @@ using LBPUnion.ProjectLighthouse.Helpers.Extensions;
|
|||
using LBPUnion.ProjectLighthouse.Logging;
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using LBPUnion.ProjectLighthouse.Types.Match;
|
||||
using LBPUnion.ProjectLighthouse.Types.Settings;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
|
@ -87,8 +86,6 @@ public class MatchController : ControllerBase
|
|||
if (playerData.RoomState != null)
|
||||
if (room != null && Equals(room.Host, user))
|
||||
room.State = (RoomState)playerData.RoomState;
|
||||
|
||||
if (ServerSettings.StartupConfigCheck && !ServerSettings.ConfigCheck()) Environment.Exit(0);
|
||||
}
|
||||
|
||||
if (matchData is FindBestRoom && MatchHelper.UserLocations.Count > 1)
|
||||
|
|
|
@ -43,9 +43,9 @@ public static class Program
|
|||
Logger.AddLogger(new LighthouseFileLogger());
|
||||
|
||||
Logger.Log("Welcome to Project Lighthouse!", LoggerLevelStartup.Instance);
|
||||
Logger.Log($"Running {VersionHelper.FullVersion}", LoggerLevelStartup.Instance);
|
||||
Logger.Log($"You are running version {VersionHelper.FullVersion}", LoggerLevelStartup.Instance);
|
||||
|
||||
// This loads the config, see ServerSettings.cs for more information
|
||||
// Referencing ServerSettings.Instance here loads the config, see ServerSettings.cs for more information
|
||||
Logger.Log("Loaded config file version " + ServerSettings.Instance.ConfigVersion, LoggerLevelStartup.Instance);
|
||||
|
||||
Logger.Log("Determining if the database is available...", LoggerLevelStartup.Instance);
|
||||
|
@ -143,6 +143,7 @@ public static class Program
|
|||
{
|
||||
webBuilder.UseStartup<Startup.Startup>();
|
||||
webBuilder.UseWebRoot("StaticFiles");
|
||||
webBuilder.UseUrls(ServerSettings.Instance.ServerListenUrl);
|
||||
}
|
||||
)
|
||||
.ConfigureLogging
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
using Kettu;
|
||||
using LBPUnion.ProjectLighthouse.Logging;
|
||||
using LBPUnion.ProjectLighthouse.Types.Settings;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Hosting.Internal;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
@ -37,7 +38,7 @@ public class DebugWarmupLifetime : IHostLifetime
|
|||
using HttpClient client = new();
|
||||
|
||||
Logger.Log("Warming up Hot Reload...", LoggerLevelStartup.Instance);
|
||||
client.GetAsync("http://localhost:10060/").Wait();
|
||||
client.GetAsync(ServerSettings.Instance.ServerListenUrl).Wait();
|
||||
Logger.Log("Hot Reload is ready to go!", LoggerLevelStartup.Instance);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,16 +6,13 @@ using System.Text.Json.Serialization;
|
|||
using JetBrains.Annotations;
|
||||
using Kettu;
|
||||
using LBPUnion.ProjectLighthouse.Logging;
|
||||
#if RELEASE
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
#endif
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Types.Settings;
|
||||
|
||||
[Serializable]
|
||||
public class ServerSettings
|
||||
{
|
||||
public const int CurrentConfigVersion = 20; // MUST BE INCREMENTED FOR EVERY CONFIG CHANGE!
|
||||
public const int CurrentConfigVersion = 21; // MUST BE INCREMENTED FOR EVERY CONFIG CHANGE!
|
||||
private static FileSystemWatcher fileWatcher;
|
||||
static ServerSettings()
|
||||
{
|
||||
|
@ -25,8 +22,6 @@ public class ServerSettings
|
|||
|
||||
if (File.Exists(ConfigFileName))
|
||||
{
|
||||
if (!(StartupConfigCheck = ConfigCheck())) return;
|
||||
|
||||
string configFile = File.ReadAllText(ConfigFileName);
|
||||
|
||||
Instance = JsonSerializer.Deserialize<ServerSettings>(configFile) ?? throw new ArgumentNullException(nameof(ConfigFileName));
|
||||
|
@ -164,6 +159,8 @@ public class ServerSettings
|
|||
|
||||
public string HCaptchaSecret { get; set; } = "";
|
||||
|
||||
public string ServerListenUrl { get; set; } = "http://localhost:10060";
|
||||
|
||||
#region Meta
|
||||
|
||||
[NotNull]
|
||||
|
@ -174,34 +171,6 @@ public class ServerSettings
|
|||
|
||||
public const string ConfigFileName = "lighthouse.config.json";
|
||||
|
||||
public static bool StartupConfigCheck;
|
||||
public static bool ConfigCheck()
|
||||
{
|
||||
#if !DEBUG
|
||||
if (VersionHelper.IsDirty)
|
||||
{
|
||||
string dirtyPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ".lighthouse");
|
||||
string dirtyFile = Path.Combine(dirtyPath, ".dirty-date");
|
||||
if (File.Exists(dirtyFile))
|
||||
{
|
||||
long timestamp = long.Parse(File.ReadAllText(dirtyFile));
|
||||
if (timestamp + 604800 < TimestampHelper.Timestamp)
|
||||
{
|
||||
Instance = new ServerSettings();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Directory.CreateDirectory(dirtyPath);
|
||||
File.WriteAllText(dirtyFile, TimestampHelper.Timestamp.ToString());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion Meta
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue