elstat/lib/supervisor.ex
2018-06-11 17:42:40 -03:00

30 lines
677 B
Elixir

defmodule Elstat.Supervisor do
use Supervisor
require Logger
def start_link(opts) do
Supervisor.start_link(__MODULE__, :ok, opts)
end
def init(:ok) do
Logger.info "starting sup"
base_children = [
%{
id: Elstat.Cowboy,
start: {Elstat.Cowboy, :start_link, []},
},
%{
id: Sqlitex.Server,
start: {Sqlitex.Server, :start_link, ['elstat.db', [name: Sqlitex.Server]]}
}
]
service_children = Elstat.Manager.build_services()
children = service_children ++ base_children
Logger.debug "final children #{inspect children}"
Supervisor.init(children, strategy: :one_for_one)
end
end