summaryrefslogtreecommitdiff
path: root/lib/lsg_irc.ex
blob: c811d18ea0508dfcdbc7e776bbe7607a76710684 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
defmodule LSG.IRC do

  def application_childs do
    env = Application.get_env(:lsg, :irc)
    import Supervisor.Spec

    IRC.Connection.setup()
    IRC.Plugin.setup()
    for plugin <- Application.get_env(:lsg, :irc)[:plugins], do: IRC.Plugin.declare(plugin)

    [
      worker(Registry, [[keys: :duplicate, name: IRC.ConnectionPubSub]], id: :registr_irc_conn),
      worker(Registry, [[keys: :duplicate, name: IRC.PubSub]], id: :registry_irc),
      worker(IRC.Membership, []),
      worker(IRC.Account, []),
      worker(IRC.UserTrack.Storage, []),
      worker(IRC.Account.AccountPlugin, []),
      supervisor(IRC.Plugin.Supervisor, [], [name: IRC.Plugin.Supervisor]),
      supervisor(IRC.Connection.Supervisor, [], [name: IRC.Connection.Supervisor]),
    ]
  end

  def after_start() do
    # Start plugins first to let them get on connection events.
    IRC.Plugin.start_all()
    IRC.Connection.start_all()
  end

end