elstat/lib/supervisor.ex

31 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