2019-10-04 09:21:45 -06:00
|
|
|
# Pleroma: A lightweight social networking server
|
2020-03-03 15:44:49 -07:00
|
|
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
2019-10-04 09:21:45 -06:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2019-09-16 04:03:37 -06:00
|
|
|
defmodule Pleroma.Web.Streamer.Supervisor do
|
|
|
|
use Supervisor
|
|
|
|
|
|
|
|
def start_link(opts) do
|
|
|
|
Supervisor.start_link(__MODULE__, opts, name: __MODULE__)
|
|
|
|
end
|
|
|
|
|
|
|
|
def init(args) do
|
|
|
|
children = [
|
|
|
|
{Pleroma.Web.Streamer.State, args},
|
|
|
|
{Pleroma.Web.Streamer.Ping, args},
|
|
|
|
:poolboy.child_spec(:streamer_worker, poolboy_config())
|
|
|
|
]
|
|
|
|
|
|
|
|
opts = [strategy: :one_for_one, name: Pleroma.Web.Streamer.Supervisor]
|
|
|
|
Supervisor.init(children, opts)
|
|
|
|
end
|
|
|
|
|
|
|
|
defp poolboy_config do
|
|
|
|
opts =
|
|
|
|
Pleroma.Config.get(:streamer,
|
|
|
|
workers: 3,
|
|
|
|
overflow_workers: 2
|
|
|
|
)
|
|
|
|
|
|
|
|
[
|
|
|
|
{:name, {:local, :streamer_worker}},
|
|
|
|
{:worker_module, Pleroma.Web.Streamer.Worker},
|
|
|
|
{:size, opts[:workers]},
|
|
|
|
{:max_overflow, opts[:overflow_workers]}
|
|
|
|
]
|
|
|
|
end
|
|
|
|
end
|