The problem: When we're going through the list of modules to send messages to based on the channels they're a part of, it was being done so through the config. Since the config doesn't (and shouldn't) list all of the core modules that get included, any core modules that were loaded and running under the ModuleSupervisor would not get included in the router's attempt to send messages to a module. Now, the Config.all_channels and Config.channel_modules functions live in State, and State has a new "add_loaded_module" function where loaded modules are registered. The aforementioned moved functions will use this as the "source of truth" when deciding where to send messages for modules to handle. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
30 lines
772 B
Elixir
30 lines
772 B
Elixir
defmodule Omnibot.Supervisor do
|
|
@moduledoc false
|
|
|
|
use Supervisor
|
|
|
|
def start_link(opts) do
|
|
Supervisor.start_link(__MODULE__, :ok, opts)
|
|
end
|
|
|
|
@impl true
|
|
def init(:ok) do
|
|
{_, bindings} = Code.eval_file("omnibot.exs")
|
|
cfg = bindings[:config]
|
|
|
|
children = [
|
|
{Task.Supervisor, name: Omnibot.RouterSupervisor, strategy: :one_for_one},
|
|
{Omnibot.State, cfg: cfg, name: Omnibot.State},
|
|
{Omnibot.ModuleSupervisor, cfg: cfg, name: Omnibot.ModuleSupervisor},
|
|
{Omnibot.Irc, name: Omnibot.Irc},
|
|
]
|
|
|
|
# TODO : how to handle config reloading?
|
|
# TODO : how to start up modules?
|
|
|
|
# :one_for_all here because the RouterSupervisor and IRC server are co-dependent
|
|
Supervisor.init(children, strategy: :one_for_all)
|
|
end
|
|
end
|
|
|