summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md6
-rw-r--r--config/config.exs1
-rw-r--r--lib/farside/application.ex17
-rwxr-xr-xupdate.sh2
4 files changed, 22 insertions, 4 deletions
diff --git a/README.md b/README.md
index 54b40dc..a2dd1da 100644
--- a/README.md
+++ b/README.md
@@ -73,3 +73,9 @@ request per second per IP.
- Run Farside: `mix run --no-halt`
- Uses localhost:4001
+### Environment Variables
+
+| Name | Purpose |
+| -- | -- |
+| FARSIDE_TEST | If enabled, skips the instance availability check in `update.exs`. |
+| FARSIDE_NO_ROUTER | If enabled, skips creation of the router. Useful for running `update.exs` with `mix run` when the app is already running. |
diff --git a/config/config.exs b/config/config.exs
index c522a9f..cbed1ef 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -1,6 +1,7 @@
import Config
config :farside,
+ port: 4001,
redis_conn: "redis://localhost:6379",
update_file: ".update-results",
service_prefix: "service-",
diff --git a/lib/farside/application.ex b/lib/farside/application.ex
index fd199e1..d1c5e25 100644
--- a/lib/farside/application.ex
+++ b/lib/farside/application.ex
@@ -1,4 +1,5 @@
defmodule Farside.Application do
+ @farside_port Application.fetch_env!(:farside, :port)
@redis_conn Application.fetch_env!(:farside, :redis_conn)
@moduledoc false
@@ -6,12 +7,22 @@ defmodule Farside.Application do
@impl true
def start(_type, _args) do
- children = [
- Plug.Cowboy.child_spec(scheme: :http, plug: Farside.Router, options: [port: 4001]),
- {Redix, {@redis_conn, [name: :redix]}},
+ plug_children = [
+ Plug.Cowboy.child_spec(
+ scheme: :http,
+ plug: Farside.Router,
+ options: [
+ port: @farside_port
+ ]
+ ),
{PlugAttack.Storage.Ets, name: Farside.Throttle.Storage, clean_period: 60_000}
]
+ children = [
+ {Redix, {@redis_conn, [name: :redix]}} |
+ System.get_env("FARSIDE_NO_ROUTER") && [] || plug_children
+ ]
+
opts = [strategy: :one_for_one, name: Farside.Supervisor]
Supervisor.start_link(children, opts)
end
diff --git a/update.sh b/update.sh
index 1ab0d52..ff14797 100755
--- a/update.sh
+++ b/update.sh
@@ -3,4 +3,4 @@
SCRIPT_DIR="$(builtin cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
cd "$SCRIPT_DIR"
-mix run update.exs
+FARSIDE_NO_ROUTER=1 mix run update.exs