From 3127130b19dd638c554f031884209739212785d5 Mon Sep 17 00:00:00 2001 From: Carl Manzi Date: Tue, 5 Jan 2021 22:25:25 -0500 Subject: [PATCH] cpu usage improvements and misc --- etc/t2server/serverprefs/Classic_CTF.cs | 52 ------------------------- setup | 2 + usr/local/bin/t2server | 22 ++++++----- usr/local/bin/t2support.py | 2 - 4 files changed, 14 insertions(+), 64 deletions(-) delete mode 100644 etc/t2server/serverprefs/Classic_CTF.cs diff --git a/etc/t2server/serverprefs/Classic_CTF.cs b/etc/t2server/serverprefs/Classic_CTF.cs deleted file mode 100644 index 9cc7c46..0000000 --- a/etc/t2server/serverprefs/Classic_CTF.cs +++ /dev/null @@ -1,52 +0,0 @@ -$Host::AdminPassword = "changethis"; -$Host::allowAdminPlayerVotes = "0"; -$Host::AllowMapScript = 1; -$Host::BanTime = 1800; -$Host::BotCount = 7; -$Host::BotsEnabled = "0"; -$Host::ClassicSuperAdminPassword = "changethis"; -$Host::CRCTextures = 0; -$Host::FloodProtectionEnabled = 1; -$Host::GameName = "Tribes 2 Classic CTF Server"; -$Host::HiVisibility = "1"; -$Host::holoName1 = "Storm"; -$Host::holoName2 = "Inferno"; -$Host::holoName3 = "Starwolf"; -$Host::holoName4 = "DSword"; -$Host::holoName5 = "BloodEagle"; -$Host::holoName6 = "Harbinger"; -$Host::Info = "This is a Tribes 2 Classic Server."; -$Host::KickBanTime = 300; -$Host::Map = "Minotaur"; -$Host::MarkDnDObjectives = 1; -$Host::MaxMessageLen = 120; -$Host::MaxPlayers = "64"; -$Host::MissionType = "CTF"; -$Host::NoSmurfs = 0; -$Host::PlayerRespawnTimeout = "60"; -$Host::Port = "28000"; -$Host::PureServer = 0; -$Host::TeamDamageOn = "1"; -$Host::TeamName0 = "Unassigned"; -$Host::TeamName1 = "Storm"; -$Host::TeamName2 = "Inferno"; -$Host::TeamName3 = "Starwolf"; -$Host::TeamName4 = "Diamond Sword"; -$Host::TeamName5 = "Blood Eagle"; -$Host::TeamName6 = "Phoenix"; -$Host::TeamSkin0 = "blank"; -$Host::TeamSkin1 = "base"; -$Host::TeamSkin2 = "baseb"; -$Host::TeamSkin3 = "swolf"; -$Host::TeamSkin4 = "dsword"; -$Host::TeamSkin5 = "beagle"; -$Host::TeamSkin6 = "cotp"; -$Host::TimeLimit = "200"; -$Host::TN::beat = 3; -$Host::TN::echo = 1; -$Host::TournamentMode = "0"; -$Host::UseHighPerformanceCounter = 0; -$Host::VotePassPercent = "60"; -$Host::VoteSpread = 20; -$Host::VoteTime = "30"; -$Host::warmupTime = "20"; diff --git a/setup b/setup index 661b90c..72d17a4 100755 --- a/setup +++ b/setup @@ -1,4 +1,6 @@ #!/usr/bin/env -S python3 -B +from tqdm import tqdm +from hashlib import md5 from os import system, unlink, symlink, makedirs, geteuid, getcwd, chmod, rename from os.path import isfile, isdir from time import time diff --git a/usr/local/bin/t2server b/usr/local/bin/t2server index 843e7c6..2cd3450 100755 --- a/usr/local/bin/t2server +++ b/usr/local/bin/t2server @@ -79,20 +79,20 @@ def server_files(config): mlist.write("") -def runaway_control(): +def runaway_control(runaway_proc_cmd): """ - When run in the background, wine will spawn a 'wineconsole --use-event=52' - process that will consume all available CPU. This function finds that - process and uses cpulimit to keep it under control. + When run in the background, wine will spawn two 'wineconsole' + processes that will consume all available CPU. This function finds these + processes and uses cpulimit to keep them under control. """ for x in range(20): sleep(15) - print("Checking for runaway wineconsole process...") - runaway_pid=run(["/usr/bin/pgrep","-f","wineconsole --use-event=52"],stdout=PIPE).stdout + print(f"Checking for runaway '{runaway_proc_cmd}' process...") + runaway_pid=run(["/usr/bin/pgrep","-f", runaway_proc_cmd],stdout=PIPE).stdout if runaway_pid: runaway_pid=str(int(runaway_pid)) print(f"Limiting runaway wineconsole process: {runaway_pid}") - run(["/usr/bin/cpulimit","-bp",runaway_pid,"-l2"]) + run(["/usr/bin/cpulimit","-bp", runaway_pid,"-l2"]) break def master_heartbeat(): @@ -178,9 +178,11 @@ if __name__ == "__main__": heartbeat.daemon=True heartbeat.start() - # Cap the CPU of the runaway wineconsole process - wcpid_limit=Thread(target=runaway_control) - wcpid_limit.start() + # Cap the CPU of the runaway wineconsole processes + wcpid1_limit=Thread(target=runaway_control, args=("wineconsole --use-event=52",)) + wcpid1_limit.start() + wcpid2_limit=Thread(target=runaway_control, args=("wineconsole --use-event=188",)) + wcpid2_limit.start() # Open the console log file if running as service and start the Tribes 2 server print(f"Starting Tribes 2 server: " + " ".join(server_command)) diff --git a/usr/local/bin/t2support.py b/usr/local/bin/t2support.py index 4dffe70..6afd43e 100644 --- a/usr/local/bin/t2support.py +++ b/usr/local/bin/t2support.py @@ -1,7 +1,5 @@ -from tqdm import tqdm from re import search from requests import get -from hashlib import md5 from os import walk from os.path import join, islink from shutil import chown