Skip to content

Commit

Permalink
Highlight events where bots & scripts crash (#70)
Browse files Browse the repository at this point in the history
* Highlight events where bots & scripts crash

* Don't name unused variables
  • Loading branch information
VirxEC authored Jan 16, 2025
1 parent 6eca856 commit ef277af
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions RLBotCS/ManagerTools/LaunchManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,27 +140,40 @@ public static void LaunchBots(
int rlbotSocketsPort
)
{
foreach (var mainPlayer in processGroups.Values)
foreach (var bot in processGroups.Values)
{
if (mainPlayer.RunCommand == "")
if (bot.RunCommand == "")
continue;

Process botProcess = RunCommandInShell(mainPlayer.RunCommand);
Process botProcess = RunCommandInShell(bot.RunCommand);

if (mainPlayer.RootDir != "")
botProcess.StartInfo.WorkingDirectory = mainPlayer.RootDir;
if (bot.RootDir != "")
botProcess.StartInfo.WorkingDirectory = bot.RootDir;

botProcess.StartInfo.EnvironmentVariables["RLBOT_AGENT_ID"] = mainPlayer.AgentId;
botProcess.StartInfo.EnvironmentVariables["RLBOT_AGENT_ID"] = bot.AgentId;
botProcess.StartInfo.EnvironmentVariables["RLBOT_SERVER_PORT"] =
rlbotSocketsPort.ToString();
botProcess.EnableRaisingEvents = true;

botProcess.Exited += (_, _) =>
{
if (botProcess.ExitCode != 0)
{
Logger.LogError(
"Bot {0} exited with error code {1}. See previous logs for more information.",
bot.Name,
botProcess.ExitCode
);
}
};

try
{
botProcess.Start();
}
catch (Exception e)
{
Logger.LogError($"Failed to launch bot {mainPlayer.Name}: {e.Message}");
Logger.LogError($"Failed to launch bot {bot.Name}: {e.Message}");
}
}
}
Expand All @@ -183,6 +196,19 @@ int rlbotSocketsPort
scriptProcess.StartInfo.EnvironmentVariables["RLBOT_AGENT_ID"] = script.AgentId;
scriptProcess.StartInfo.EnvironmentVariables["RLBOT_SERVER_PORT"] =
rlbotSocketsPort.ToString();
scriptProcess.EnableRaisingEvents = true;

scriptProcess.Exited += (_, _) =>
{
if (scriptProcess.ExitCode != 0)
{
Logger.LogError(
"Script {0} exited with error code {1}. See previous logs for more information.",
script.Name,
scriptProcess.ExitCode
);
}
};

try
{
Expand Down

0 comments on commit ef277af

Please sign in to comment.