Skip to content

Commit

Permalink
Added config for distribution support
Browse files Browse the repository at this point in the history
  • Loading branch information
vloothuis committed Oct 26, 2023
1 parent 46597e7 commit 2d137d3
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,13 @@ if config_env() == :prod do
# The public URL must point to the root's (bucket) publicly accessible URL.
# It should have a policy that allows anonymous users to read all files.
public_url: System.get_env("FELDSPAR_S3_PUBLIC_URL")

config :core,
:dist_hosts,
"DIST_HOSTS"
|> System.get_env("")
|> String.split(",")
|> Enum.map(&String.trim/1)
|> Enum.reject(&(&1 == ""))
|> Enum.map(&String.to_atom/1)
end
12 changes: 12 additions & 0 deletions core/lib/core/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ defmodule Core.Application do
use Application

def start(_type, _args) do
topologies = [
example: [
strategy: Cluster.Strategy.Epmd,
config: [hosts: dist_hosts()]
]
]

children = [
{Cluster.Supervisor, [topologies, [name: MyApp.ClusterSupervisor]]},
Core.Repo,
CoreWeb.Telemetry,
{Phoenix.PubSub, name: Core.PubSub},
Expand All @@ -31,4 +39,8 @@ defmodule Core.Application do
defp rate_config do
Application.fetch_env!(:core, :rate)
end

defp dist_hosts do
Application.get_env(:core, :dist_hosts, [])
end
end
1 change: 1 addition & 0 deletions core/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ defmodule Core.MixProject do
{:statistics, "~> 0.6.2"},
{:csv, "~> 2.4"},
{:sentry, "~> 8.0"},
{:libcluster, "~> 3.3"},
# i18n
{:ex_cldr, "~> 2.25"},
{:ex_cldr_numbers, "~> 2.23"},
Expand Down
1 change: 1 addition & 0 deletions core/mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"joken": {:hex, :joken, "2.6.0", "b9dd9b6d52e3e6fcb6c65e151ad38bf4bc286382b5b6f97079c47ade6b1bcc6a", [:mix], [{:jose, "~> 1.11.5", [hex: :jose, repo: "hexpm", optional: false]}], "hexpm", "5a95b05a71cd0b54abd35378aeb1d487a23a52c324fa7efdffc512b655b5aaa7"},
"jose": {:hex, :jose, "1.11.5", "3bc2d75ffa5e2c941ca93e5696b54978323191988eb8d225c2e663ddfefd515e", [:mix, :rebar3], [], "hexpm", "dcd3b215bafe02ea7c5b23dafd3eb8062a5cd8f2d904fd9caa323d37034ab384"},
"kadabra": {:hex, :kadabra, "0.6.0", "8d8de886802f38d86d2c250eb9416e3208b5e4b78ce8409b40b4d57f21d21fc9", [:mix], [{:certifi, "~> 2.5", [hex: :certifi, repo: "hexpm", optional: false]}, {:hpack, "~> 0.2.3", [hex: :hpack_erl, repo: "hexpm", optional: false]}], "hexpm", "0cdaf72fc6205cba62da9e49ee6b24b7c50adb6d9f8b0e92b4b1847959371403"},
"libcluster": {:hex, :libcluster, "3.3.3", "a4f17721a19004cfc4467268e17cff8b1f951befe428975dd4f6f7b84d927fe0", [:mix], [{:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "7c0a2275a0bb83c07acd17dab3c3bfb4897b145106750eeccc62d302e3bdfee5"},
"logger_json": {:hex, :logger_json, "4.3.0", "41aaaab2c2e1c071bfddbcc5a3f567884fdf312d222c7f1a7e3de6ab667774f7", [:mix], [{:ecto, "~> 2.1 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "001bbc34d7c451cfeed298c8384cb3aab10b364db2eb095c466c7a1a28bee6e0"},
"luhn": {:hex, :luhn, "0.3.3", "5aa0c6a32c2db4b9db9f9b883ba8301c1ae169d57199b9e6cb1ba2707bc51d96", [:mix], [], "hexpm", "3e823a913a25aab51352c727f135278d22954874d5f0835be81ed4fec3daf78d"},
"mail": {:hex, :mail, "0.2.3", "2c6bb5f8a5f74845fa50ecd0fb45ea16b164026f285f45104f1c4c078cd616d4", [:mix], [], "hexpm", "932b398fa9c69fdf290d7ff63175826e0f1e24414d5b0763bb00a2acfc6c6bf5"},
Expand Down
8 changes: 8 additions & 0 deletions core/rel/env.bat.eex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@echo off
rem Set the release to load code on demand (interactive) instead of preloading (embedded).
rem set RELEASE_MODE=interactive

rem Set the release to work across nodes.
rem RELEASE_DISTRIBUTION must be "sname" (local), "name" (distributed) or "none".
rem set RELEASE_DISTRIBUTION=name
rem set RELEASE_NODE=<%= @release.name %>
24 changes: 24 additions & 0 deletions core/rel/env.sh.eex
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

# # Sets and enables heart (recommended only in daemon mode)
# case $RELEASE_COMMAND in
# daemon*)
# HEART_COMMAND="$RELEASE_ROOT/bin/$RELEASE_NAME $RELEASE_COMMAND"
# export HEART_COMMAND
# export ELIXIR_ERL_OPTIONS="-heart"
# ;;
# *)
# ;;
# esac

# # Set the release to load code on demand (interactive) instead of preloading (embedded).
# export RELEASE_MODE=interactive

# # Set the release to work across nodes.
# # RELEASE_DISTRIBUTION must be "sname" (local), "name" (distributed) or "none".
# export RELEASE_DISTRIBUTION=name
# export RELEASE_NODE=<%= @release.name %>

if [ ! -z "${DIST_TLS_CONF}" ]; then
export ELIXIR_ERL_OPTIONS="-proto_dist inet_tls -ssl_dist_optfile ${DIST_TLS_CONF}"
fi
8 changes: 8 additions & 0 deletions core/rel/remote.vm.args.eex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Customize flags given to the VM: https://www.erlang.org/doc/man/erl.html
## -mode/-name/-sname/-setcookie are configured via env vars, do not set them here

## Increase number of concurrent ports/sockets
##+Q 65536

## Tweak GC to run more often
##-env ERL_FULLSWEEP_AFTER 10
9 changes: 9 additions & 0 deletions core/rel/vm.args.eex
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Customize flags given to the VM: https://www.erlang.org/doc/man/erl.html
## -mode/-name/-sname/-setcookie are configured via env vars, do not set them here

## Increase number of concurrent ports/sockets
##+Q 65536

## Tweak GC to run more often
##-env ERL_FULLSWEEP_AFTER 10
-kernel inet_dist_listen_min 4370 inet_dist_listen_max 4500

0 comments on commit 2d137d3

Please sign in to comment.