From 75ed3bad0defd844f29daf0e522520318420c9a4 Mon Sep 17 00:00:00 2001 From: Thurloat Date: Tue, 11 Sep 2018 09:59:06 -0300 Subject: [PATCH] better configuration, better README for releases --- README.md | 8 +++++++- config/config.exs | 5 +++-- config/prod.exs | 4 ++++ lib/dough.ex | 19 +++++++++++++------ 4 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 config/prod.exs diff --git a/README.md b/README.md index f03289f..133d0e2 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,13 @@ proxy server from sources they actually trust. ## Running the server -You can compile a release by running `MIX_ENV=prod mix release`. +You can compile a release by running the following: + +``` +export REPLACE_OS_VARS=true +export MIX_ENV=prod +mix release --env=prod +``` Then to run the server, you can supply your own DNS server via the DOUGH_DNS environment variable. diff --git a/config/config.exs b/config/config.exs index 0c1de75..1466de7 100644 --- a/config/config.exs +++ b/config/config.exs @@ -4,6 +4,7 @@ use Mix.Config config :dough, # default, an opennic server. - dns_server: "37.235.1.174" + dns_server: "37.235.1.174", + current_version: Mix.Project.config()[:version] -# import_config "#{Mix.env}.exs" +import_config "#{Mix.env}.exs" diff --git a/config/prod.exs b/config/prod.exs new file mode 100644 index 0000000..7a7d103 --- /dev/null +++ b/config/prod.exs @@ -0,0 +1,4 @@ +use Mix.Config + +config :dough, + dns_server: "${DOUGH_DNS}" diff --git a/lib/dough.ex b/lib/dough.ex index 0d6c2f3..b475302 100644 --- a/lib/dough.ex +++ b/lib/dough.ex @@ -6,12 +6,10 @@ defmodule Dough do import Supervisor.Spec import Cachex.Spec + import Logger + def start(_type, _args) do - # List all child processes to be supervised children = [ - # Starts a worker by calling: Dough.Worker.start_link(arg) - # {Dough.Worker, arg}, - # Plug.Adapters.Cowboy.child_spec(:https, Dough.Router, [], port: 8331, keyfile: "priv/ssl/localhost.key", certfile: "priv/ssl/localhost.crt", otp_app: :dough) worker(Cachex, [ :dough, [ @@ -34,8 +32,17 @@ defmodule Dough do ]} ] - # See https://hexdocs.pm/elixir/Supervisor.html - # for other strategies and supported options + Logger.info(" +██▄ ████▄ ▄ ▄▀ ▄ █ +█ █ █ █ █ ▄▀ █ █ +█ █ █ █ █ █ █ ▀▄ ██▀▀█ +█ █ ▀████ █ █ █ █ █ █ +███▀ █▄ ▄█ ███ █ + ▀▀▀ ▀ +Starting Dough Server #{Application.get_env(:dough, :current_version)} ... +DNS Proxying to #{Application.get_env(:dough, :dns_server)} +") + opts = [strategy: :one_for_one, name: Dough.Supervisor] Supervisor.start_link(children, opts) end