Skip to content

Commit

Permalink
battle process exit after some time
Browse files Browse the repository at this point in the history
This is a temporary measure until we hook these process with autohost
messages.
  • Loading branch information
geekingfrog committed Feb 8, 2025
1 parent dd2dedc commit 33e5079
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/teiserver/tachyon_battle/battle.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ defmodule Teiserver.TachyonBattle.Battle do
autohost_timeout: Map.get(args, :autohost_timeout, 10)
}

# because the battle system is not yet hooked up with anything whenever
# a battle is started it'll stay around forever. So to be 100% sure that
# it's not going to cause any issue, shut down the battle after some time
:timer.send_after(5 * 60_000, :die)

case Teiserver.Autohost.lookup_autohost(autohost_id) do
{pid, _} ->
Logger.info("init battle for autohost #{autohost_id}")
Expand All @@ -59,6 +64,11 @@ defmodule Teiserver.TachyonBattle.Battle do
{:stop, :normal, state}
end

def handle_info(:die, state) do
Logger.info("Battle shutting down to save resources")
{:stop, :normal, state}
end

defp via_tuple(battle_id) do
Registry.via_tuple(battle_id)
end
Expand Down

0 comments on commit 33e5079

Please sign in to comment.