From 9b5133dcbb39114a7f7ab84e0313d4f7035df123 Mon Sep 17 00:00:00 2001 From: Logan Hunt Date: Wed, 1 Feb 2023 10:25:20 -0700 Subject: [PATCH] Fuck it. Environment variable hack. --- buildscripts/build/build.sh | 1 + config/dev.exs | 8 -------- config/prod.exs | 17 ----------------- config/runtime.exs | 17 +++++++++++++++++ config/test.exs | 8 -------- 5 files changed, 18 insertions(+), 33 deletions(-) diff --git a/buildscripts/build/build.sh b/buildscripts/build/build.sh index 3cc5717..5930c00 100755 --- a/buildscripts/build/build.sh +++ b/buildscripts/build/build.sh @@ -151,6 +151,7 @@ function build_server() { cp "${build_dir}/.env" $temp_file printf "\nNODE_ID=$node_conn\nRELEASE_NODE=chessh@192.168.100.${node_id}\nRELEASE_DISTRIBUTION=name\nRELEASE_COOKIE=chessh\n" >> $temp_file + printf "CLUSTER_NODES=$(printf "chessh@192.168.100.%s," ${server_node_ids[@]})\n" >> $temp_file scp $ssh_opts $temp_file $node_conn:~/.env cp "${build_dir}/chessh.service" $temp_file diff --git a/config/dev.exs b/config/dev.exs index 0881420..f37da7b 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -12,11 +12,3 @@ config :hammer, {Hammer.Backend.ETS, [expiry_ms: 60_000 * 60 * 4, cleanup_interval_ms: 60_000 * 10]}, redis: {Hammer.Backend.ETS, [expiry_ms: 60_000 * 60 * 4, cleanup_interval_ms: 60_000 * 10]} ] - -config :libcluster, - topologies: [ - chessh_dev: [ - strategy: Elixir.Cluster.Strategy.ErlangHosts, - config: [timeout: 30_000] - ] - ] diff --git a/config/prod.exs b/config/prod.exs index 838a637..bb12243 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -10,20 +10,3 @@ config :chessh, RateLimits, max_concurrent_user_sessions: 5, player_session_message_burst_ms: 750, player_session_message_burst_rate: 8 - -config :libcluster, - topologies: [ - chessh: [ - strategy: Elixir.Cluster.Strategy.Gossip, - config: [ - port: 45892, - if_addr: "0.0.0.0", - multicast_if: "192.168.1.1", - multicast_addr: "233.252.255.255", - multicast_ttl: 1 - ] - ] - ] - -config :libcluster, - debug: true diff --git a/config/runtime.exs b/config/runtime.exs index ebdb2cc..19078c5 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -13,6 +13,23 @@ config :chessh, Web, System.get_env("SERVER_REDIRECT_URI", "http://127.0.0.1:3000/api/oauth/redirect"), port: String.to_integer(System.get_env("WEB_PORT", "8080")) +config :libcluster, + topologies: [ + chessh: [ + strategy: Cluster.Strategy.Epmd, + config: [ + hosts: + String.split(System.get_env("CLUSTER_NODES", ""), ",") + |> Enum.filter(fn x -> String.length(x) > 0 end) + |> Enum.map(&String.to_atom/1) + ], + connect: {:net_kernel, :connect, []}, + disconnect: {:net_kernel, :disconnect, []}, + list_nodes: {:erlang, :nodes, [:connected]}, + child_spec: [restart: :transient] + ] + ] + config :joken, default_signer: System.get_env("JWT_SECRET") diff --git a/config/test.exs b/config/test.exs index 83ee6f1..a4fd692 100644 --- a/config/test.exs +++ b/config/test.exs @@ -18,14 +18,6 @@ config :hammer, redis: {Hammer.Backend.ETS, [expiry_ms: 60_000 * 60 * 4, cleanup_interval_ms: 60_000 * 10]} ] -config :libcluster, - topologies: [ - chessh_test: [ - strategy: Elixir.Cluster.Strategy.Epmd - ] - ] - - config :chessh, ssh_port: 42_069, key_dir: Path.join(Path.dirname(__DIR__), "priv/test_keys")