summaryrefslogtreecommitdiff
path: root/lib/poolparty/supervisor.ex
blob: 9995a3dc98ed1c5977c776c26df6ee7b4275c515 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
defmodule PoolParty.Supervisor do
  use Supervisor
  require Logger

  def start_link(opts \\ []) do
    Logger.debug("[#{__MODULE__}]: Starting Pool Party Supervisor")
    Supervisor.start_link(__MODULE__, {}, [name: __MODULE__] ++ opts)
  end

  def init(_) do
    Logger.debug("[#{__MODULE__}]: Initializing Pool Party Supervisor")
    pool_size = Application.get_env(:poolparty, :pool_size)
    Logger.debug("[#{__MODULE__}]: Pool size: #{pool_size}")
    children = [worker(PoolParty.Scheduler, [pool_size]),
                worker(PoolParty.Pool.Supervisor, [pool_size])]
    supervise(children, strategy: :one_for_one)
  end
end