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
|
||||
@moduledoc """
|
||||
Documentation for `HAHandler`.
|
||||
"""
|
||||
@moduledoc false
|
||||
|
||||
@doc """
|
||||
Hello world.
|
||||
|
||||
## Examples
|
||||
|
||||
iex> HAHandler.hello()
|
||||
:world
|
||||
|
||||
"""
|
||||
def hello do
|
||||
:world
|
||||
end
|
||||
def http_port, do: Application.get_env(:ha_handler, :http_port)
|
||||
def haproxy_socket, do: Application.get_env(:ha_handler, :haproxy_socket)
|
||||
end
|
||||
|
|
|
@ -5,10 +5,12 @@ defmodule HAHandler.Application do
|
|||
|
||||
use Application
|
||||
|
||||
import HAHandler
|
||||
|
||||
@impl true
|
||||
def start(_type, _args) do
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue