mirror of
https://github.com/benbusby/farside.git
synced 2025-04-20 02:48:42 +00:00
Remove FARSIDE_NO_ROUTER
env var
The FARSIDE_NO_ROUTER variable wasn't terribly useful after refactoring the app to include the update routine internally (rather than available externally as an elixir script). Now the only supported environment variable is FARSIDE_TEST, which is still useful for tests and quick validation of functionality.
This commit is contained in:
parent
f887ad0400
commit
1092350fcd
3 changed files with 16 additions and 22 deletions
|
@ -55,7 +55,7 @@ A user navigates to `/nitter` and is redirected to `nitter.net`. The next user
|
||||||
to request `/nitter` will be guaranteed to not be directed to `nitter.net`, and
|
to request `/nitter` will be guaranteed to not be directed to `nitter.net`, and
|
||||||
will instead be redirected to a separate (random) working instance. That
|
will instead be redirected to a separate (random) working instance. That
|
||||||
instance will now take the place of `nitter.net` as the "reserved" instance, and
|
instance will now take the place of `nitter.net` as the "reserved" instance, and
|
||||||
`nitter.net` will be returned to the list of available Nitter instances.
|
`nitter.net` will be returned to the list of available Nitter instances.
|
||||||
|
|
||||||
This "reserving" of previously chosen instances is performed in an attempt to
|
This "reserving" of previously chosen instances is performed in an attempt to
|
||||||
ensure better distribution of traffic to available instances for each service.
|
ensure better distribution of traffic to available instances for each service.
|
||||||
|
@ -77,5 +77,4 @@ request per second per IP.
|
||||||
|
|
||||||
| Name | Purpose |
|
| Name | Purpose |
|
||||||
| -- | -- |
|
| -- | -- |
|
||||||
| FARSIDE_TEST | If enabled, skips the instance availability check in `update.exs`. |
|
| FARSIDE_TEST | If enabled, bypasses the instance availability check and adds all instances to the pool. |
|
||||||
| FARSIDE_NO_ROUTER | If enabled, skips creation of the router. Useful for running `update.exs` with `mix run` when the app is already running. |
|
|
||||||
|
|
|
@ -7,25 +7,19 @@ defmodule Farside.Application do
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def start(_type, _args) do
|
def start(_type, _args) do
|
||||||
plug_children =
|
children = [
|
||||||
(System.get_env("FARSIDE_NO_ROUTER") && []) ||
|
Plug.Cowboy.child_spec(
|
||||||
[
|
scheme: :http,
|
||||||
Plug.Cowboy.child_spec(
|
plug: Farside.Router,
|
||||||
scheme: :http,
|
options: [
|
||||||
plug: Farside.Router,
|
port: @farside_port
|
||||||
options: [
|
|
||||||
port: @farside_port
|
|
||||||
]
|
|
||||||
),
|
|
||||||
{PlugAttack.Storage.Ets, name: Farside.Throttle.Storage, clean_period: 60_000}
|
|
||||||
]
|
]
|
||||||
|
),
|
||||||
children =
|
{PlugAttack.Storage.Ets, name: Farside.Throttle.Storage, clean_period: 60_000},
|
||||||
[
|
{Redix, {@redis_conn, [name: :redix]}},
|
||||||
{Redix, {@redis_conn, [name: :redix]}},
|
Farside.Scheduler,
|
||||||
Farside.Scheduler,
|
Farside.Server
|
||||||
Farside.Server
|
]
|
||||||
] ++ plug_children
|
|
||||||
|
|
||||||
opts = [strategy: :one_for_one, name: Farside.Supervisor]
|
opts = [strategy: :one_for_one, name: Farside.Supervisor]
|
||||||
Supervisor.start_link(children, opts)
|
Supervisor.start_link(children, opts)
|
||||||
|
|
|
@ -45,7 +45,8 @@ defmodule Farside.Instances do
|
||||||
|
|
||||||
result =
|
result =
|
||||||
Enum.filter(service.instances, fn instance_url ->
|
Enum.filter(service.instances, fn instance_url ->
|
||||||
request_url = instance_url <>
|
request_url =
|
||||||
|
instance_url <>
|
||||||
EEx.eval_string(
|
EEx.eval_string(
|
||||||
service.test_url,
|
service.test_url,
|
||||||
query: Enum.random(@queries)
|
query: Enum.random(@queries)
|
||||||
|
|
Loading…
Add table
Reference in a new issue