Skip to content

Commit

Permalink
1.2.2
Browse files Browse the repository at this point in the history
Add MA logging ([date]-MA_output_log.txt)
Game logs iwll now be this format: [date]-SPC_output_log.txt
Better config reload handeling.
All server restarts will now be soft (multiadmin wont restart).
MemoryChecker was checking memory wrong way around (code was taken from
localadmin so ???), it will now work as intended.
TitleBar will now show the PID.
  • Loading branch information
Courtney May committed Feb 10, 2018
1 parent 0c00644 commit 0a7a291
Show file tree
Hide file tree
Showing 20 changed files with 122 additions and 25 deletions.
Binary file modified mutliadmin/.vs/MultiAdmin/v15/Server/sqlite3/storage.ide
Binary file not shown.
7 changes: 7 additions & 0 deletions mutliadmin/MultiAdmin/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ namespace MultiAdmin
public class Config
{
public Dictionary<String, String> values;
private String config_file;
public Config(String config_file)
{
this.config_file = config_file;
Reload();
}

public void Reload()
{
values = new Dictionary<string, string>();
var multi_line_value = false;
Expand Down
1 change: 1 addition & 0 deletions mutliadmin/MultiAdmin/Feature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public Feature(Server server)
}

public abstract String GetFeatureDescription();
public abstract void OnConfigReload();
public abstract String GetFeatureName();
public abstract void Init();

Expand Down
4 changes: 4 additions & 0 deletions mutliadmin/MultiAdmin/Features/Autoscale.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public Autoscale(Server server) : base(server)
}

public override void Init()
{
}

public override void OnConfigReload()
{
config = Server.ServerConfig.GetValue("START_CONFIG_ON_FULL", "disabled");
}
Expand Down
4 changes: 4 additions & 0 deletions mutliadmin/MultiAdmin/Features/ChainStart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ public override string GetFeatureName()
return "ChainStart";
}

public override void OnConfigReload()
{
}


public void OnServerStart()
{
Expand Down
10 changes: 10 additions & 0 deletions mutliadmin/MultiAdmin/Features/ConfigReload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,20 @@ public void OnCall(string[] args)
{
Server.SwapConfigs();
pass = true;
Server.ServerConfig.Reload();
Server.Log("Reloading config");
foreach (Feature feature in Server.Features)
{
feature.OnConfigReload();
}
}

}

public override void OnConfigReload()
{
}

public bool PassToGame()
{
return pass;
Expand Down
4 changes: 4 additions & 0 deletions mutliadmin/MultiAdmin/Features/EventTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ public override void Init()
{
}

public override void OnConfigReload()
{
}

public override string GetFeatureDescription()
{
return "Tests the events";
Expand Down
5 changes: 4 additions & 1 deletion mutliadmin/MultiAdmin/Features/ExitCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public string GetCommand()
return "EXIT";
}

public override void OnConfigReload()
{
}

public string GetCommandDescription()
{
return "Exits the server";
Expand Down Expand Up @@ -47,7 +51,6 @@ public override void Init()
public void OnCall(string[] args)
{
Server.StopServer(false);

}

public bool PassToGame()
Expand Down
4 changes: 4 additions & 0 deletions mutliadmin/MultiAdmin/Features/GithubGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ public GithubGenerator(Server server) : base(server)
{
}

public override void OnConfigReload()
{
}

public string GetCommand()
{
return "GITHUBGEN";
Expand Down
4 changes: 4 additions & 0 deletions mutliadmin/MultiAdmin/Features/HelpCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ public string GetCommand()
return "HELP";
}

public override void OnConfigReload()
{
}

public string GetCommandDescription()
{
return "Prints out available commands and their function.";
Expand Down
6 changes: 5 additions & 1 deletion mutliadmin/MultiAdmin/Features/InactivityShutdown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ public InactivityShutdown(Server server) : base(server)

public override void Init()
{
waitFor = Server.ServerConfig.GetIntValue("SHUTDOWN_ONCE_EMPTY_FOR", -1);
roundEndTime = Utils.GetUnixTime();
}

public override void OnConfigReload()
{
waitFor = Server.ServerConfig.GetIntValue("SHUTDOWN_ONCE_EMPTY_FOR", -1);
}

public void OnRoundEnd()
{
roundEndTime = Utils.GetUnixTime();
Expand Down
20 changes: 14 additions & 6 deletions mutliadmin/MultiAdmin/Features/MemoryChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public MemoryChecker(Server server) : base(server)

public override void Init()
{
lowMb = Server.ServerConfig.GetIntValue("RESTART_LOW_MEMORY", 400);
tickCount = 0;
}

Expand All @@ -32,22 +31,31 @@ public override string GetFeatureName()

public void OnTick()
{
long workingMemory = Server.GetGameProccess().WorkingSet64 / 1048576L;
Boolean runningFor3Mins = (Server.GetGameProccess().StartTime.AddMinutes(3.0) < DateTime.Now);
if (workingMemory < lowMb && runningFor3Mins)
Server.GetGameProccess().Refresh();
long workingMemory = Server.GetGameProccess().WorkingSet64 / 1048576L; // process memory in MB
long memoryLeft = 2048 - workingMemory; // 32 bit limited to 2GB

if (memoryLeft < lowMb)
{
Server.Write("Warning: program is running low on memory (" + memoryLeft + " MB left)");
tickCount++;
}
else
{
tickCount = 0;
}

if (tickCount == 5)
if (tickCount == 10)
{
Server.RestartServer();
Server.Write("Restarting due to lower memory");
Server.SoftRestartServer();
}

}

public override void OnConfigReload()
{
lowMb = Server.ServerConfig.GetIntValue("RESTART_LOW_MEMORY", 400);
}
}
}
4 changes: 4 additions & 0 deletions mutliadmin/MultiAdmin/Features/MultiAdminInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public override void Init()
{
}

public override void OnConfigReload()
{
}

public void PrintInfo()
{
Server.Write("MultiAdmin for SCP: Secret Laboratory made by Courtney (Grover_c13), who is not a girl.", ConsoleColor.DarkMagenta);
Expand Down
4 changes: 4 additions & 0 deletions mutliadmin/MultiAdmin/Features/NewCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public NewCommand(Server server) : base(server)
}

public override void Init()
{
}

public override void OnConfigReload()
{
config = Server.ServerConfig.GetValue("START_CONFIG_ON_FULL", "disabled");
}
Expand Down
7 changes: 6 additions & 1 deletion mutliadmin/MultiAdmin/Features/RestartNextRound.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public string GetCommandDescription()
return "Restarts the server at the end of this round";
}


public void OnCall(string[] args)
{
Server.Write("Server will restart next round");
Expand All @@ -32,7 +33,7 @@ public void OnCall(string[] args)

public void OnRoundEnd()
{
if (restart) base.Server.RestartServer();
if (restart) base.Server.SoftRestartServer();
}

public bool PassToGame()
Expand Down Expand Up @@ -64,5 +65,9 @@ public string GetUsage()
{
return "";
}

public override void OnConfigReload()
{
}
}
}
6 changes: 5 additions & 1 deletion mutliadmin/MultiAdmin/Features/RestartRoundCounter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ public RestartRoundCounter(Server server) : base(server)
public override void Init()
{
count = 0;
}

public override void OnConfigReload()
{
restartAfter = Server.ServerConfig.GetIntValue("RESTART_EVERY_NUM_ROUNDS", -1);
}

public void OnRoundEnd()
{
if (restartAfter < 0) return;
count++;
if (count > restartAfter) base.Server.RestartServer();
if (count > restartAfter) base.Server.SoftRestartServer();
}


Expand Down
5 changes: 5 additions & 0 deletions mutliadmin/MultiAdmin/Features/StopNextRound.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public override void Init()
stop = false;
}


public override void OnConfigReload()
{
}

public void OnCall(string[] args)
{
stop = true;
Expand Down
7 changes: 6 additions & 1 deletion mutliadmin/MultiAdmin/Features/TitleBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public override void Init()
UpdateTitlebar();
}

public override void OnConfigReload()
{
}

public void OnPlayerConnect(String name)
{
playerCount++;
Expand All @@ -59,7 +63,8 @@ public void UpdateTitlebar()
}
var displayPlayerCount = playerCount;
if (playerCount == -1) displayPlayerCount = 0;
Console.Title = "SCP:SL MultiAdmin " + Server.MA_VERSION + " | Config: " + Server.ConfigKey + " | Session ID:" + Server.GetSessionId() + " | " + displayPlayerCount + "/" + maxPlayers + " | " + smod;
string proccessId = (Server.GetGameProccess() == null) ? "" : Server.GetGameProccess().Id.ToString();
Console.Title = "SCP:SL MultiAdmin " + Server.MA_VERSION + " | Config: " + Server.ConfigKey + " | Session ID:" + Server.GetSessionId() + " Game PID: " + proccessId+ " | " + displayPlayerCount + "/" + maxPlayers + " | " + smod;
}
}
}
4 changes: 2 additions & 2 deletions mutliadmin/MultiAdmin/OutputThread.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ public static void Read(Server server)
catch
{
server.Write("Message printer warning: 'SCPSL_Data/Dedicated' directory not found.", ConsoleColor.Yellow);
server.Write("Press any key to ignore...", ConsoleColor.DarkGray);
Console.ReadKey();
}

foreach (string path in strArray)
Expand Down Expand Up @@ -154,6 +152,7 @@ public static void Read(Server server)
if (gameMessage.Contains("Player connect"))
{
display = false;
server.Log("Player connect event");
foreach (Feature f in server.Features)
{
if (f is IEventPlayerConnect)
Expand All @@ -167,6 +166,7 @@ public static void Read(Server server)
if (gameMessage.Contains("Player disconnect"))
{
display = false;
server.Log("Player disconnect event");
foreach (Feature f in server.Features)
{
if (f is IEventPlayerDisconnect)
Expand Down
Loading

0 comments on commit 0a7a291

Please sign in to comment.