summaryrefslogtreecommitdiff
path: root/lib/chessh/application.ex
diff options
context:
space:
mode:
authorSimponic <loganhunt@simponic.xyz>2022-12-31 02:29:38 -0700
committerSimponic <loganhunt@simponic.xyz>2022-12-31 02:31:58 -0700
commit58d0b1a89c461467c9ea6229f9a6b3d5ed573da5 (patch)
treef0e91ce7bccb93e755357395f1ed7a7a18d6257b /lib/chessh/application.ex
parent3308036c0859dcca2d80d80396a19a3cca269e78 (diff)
downloadchessh-58d0b1a89c461467c9ea6229f9a6b3d5ed573da5.tar.gz
chessh-58d0b1a89c461467c9ea6229f9a6b3d5ed573da5.zip
A simple stalling TUI! Also, ensure sessions are counted correctly. Next up, some way of pub-sub across multiple nodes
Diffstat (limited to 'lib/chessh/application.ex')
-rw-r--r--lib/chessh/application.ex7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/chessh/application.ex b/lib/chessh/application.ex
index 4692489..4b03169 100644
--- a/lib/chessh/application.ex
+++ b/lib/chessh/application.ex
@@ -2,10 +2,13 @@ defmodule Chessh.Application do
alias Chessh.{PlayerSession, Node}
use Application
- def initialize_player_sessions_on_node() do
+ def initialize_node() do
# If we have more than one node running the ssh daemon, we'd want to ensure
# this is restarting after every potential crash. Otherwise the player sessions
# on the node would hang.
+
+ # User session also need to be cleaned up after the node exits the pool for
+ # the same reason.
node_id = System.fetch_env!("NODE_ID")
Node.boot(node_id)
PlayerSession.delete_all_on_node(node_id)
@@ -16,7 +19,7 @@ defmodule Chessh.Application do
opts = [strategy: :one_for_one, name: Chessh.Supervisor]
with {:ok, pid} <- Supervisor.start_link(children, opts) do
- initialize_player_sessions_on_node()
+ initialize_node()
{:ok, pid}
end
end