mirror of
https://github.com/benbusby/farside.git
synced 2025-04-20 19:08:42 +00:00

Connection values (such as redis server port and the port to run farside on) as well as the services json file to use can now be set via environment variables: FARSIDE_PORT sets the port for Farside to run on FARSIDE_REDIS_PORT sets the redis server port for Farside to use FARSIDE_SERVICES_JSON sets the services json file for Farside to use This partially addresses the move towards de-listing Cloudflare instances by default by allowing different services json files to be used with different redis servers. See #43
32 lines
936 B
Elixir
32 lines
936 B
Elixir
defmodule Farside.Application do
|
|
#@farside_port Application.fetch_env!(:farside, :port)
|
|
#@redis_conn Application.fetch_env!(:farside, :redis_conn)
|
|
@moduledoc false
|
|
|
|
use Application
|
|
|
|
@impl true
|
|
def start(_type, _args) do
|
|
redis_conn = Application.fetch_env!(:farside, :redis_conn)
|
|
farside_port = Application.fetch_env!(:farside, :port)
|
|
IO.puts "Runing on http://localhost:#{farside_port}"
|
|
IO.puts "Redis conn: #{redis_conn}"
|
|
|
|
children = [
|
|
Plug.Cowboy.child_spec(
|
|
scheme: :http,
|
|
plug: Farside.Router,
|
|
options: [
|
|
port: String.to_integer(farside_port)
|
|
]
|
|
),
|
|
{PlugAttack.Storage.Ets, name: Farside.Throttle.Storage, clean_period: 60_000},
|
|
{Redix, {redis_conn, [name: :redix]}},
|
|
Farside.Scheduler,
|
|
Farside.Server
|
|
]
|
|
|
|
opts = [strategy: :one_for_one, name: Farside.Supervisor]
|
|
Supervisor.start_link(children, opts)
|
|
end
|
|
end
|