Add minimal configuration system
This commit is contained in:
parent
722bb69415
commit
bea2f03f97
3 changed files with 12 additions and 16 deletions
6
config/config.exs
Normal file
6
config/config.exs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import Config
|
||||||
|
|
||||||
|
config :ha_handler,
|
||||||
|
http_port: 4000,
|
||||||
|
haproxy_socket: System.get_env("HAPROXY_SOCKET") || "/var/run/haproxy.sock"
|
||||||
|
|
|
@ -1,18 +1,6 @@
|
||||||
defmodule HAHandler do
|
defmodule HAHandler do
|
||||||
@moduledoc """
|
@moduledoc false
|
||||||
Documentation for `HAHandler`.
|
|
||||||
"""
|
|
||||||
|
|
||||||
@doc """
|
def http_port, do: Application.get_env(:ha_handler, :http_port)
|
||||||
Hello world.
|
def haproxy_socket, do: Application.get_env(:ha_handler, :haproxy_socket)
|
||||||
|
|
||||||
## Examples
|
|
||||||
|
|
||||||
iex> HAHandler.hello()
|
|
||||||
:world
|
|
||||||
|
|
||||||
"""
|
|
||||||
def hello do
|
|
||||||
:world
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,10 +5,12 @@ defmodule HAHandler.Application do
|
||||||
|
|
||||||
use Application
|
use Application
|
||||||
|
|
||||||
|
import HAHandler
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def start(_type, _args) do
|
def start(_type, _args) do
|
||||||
children = [
|
children = [
|
||||||
{Plug.Cowboy, scheme: :http, plug: HAHandler.Web, options: [port: 4000]}
|
{Plug.Cowboy, scheme: :http, plug: HAHandler.Web, options: [port: http_port()]}
|
||||||
]
|
]
|
||||||
|
|
||||||
# See https://hexdocs.pm/elixir/Supervisor.html
|
# See https://hexdocs.pm/elixir/Supervisor.html
|
||||||
|
|
Loading…
Reference in a new issue