summaryrefslogblamecommitdiff
path: root/lib/lsg_irc.ex
blob: ba0828a3e726f8ba7c01a06eb2a91452f99c1807 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                    

                

                           
                                         
                          


                          


                                                                                            
 
     
                                                                                                
                                                                                  

                                 
                                        


                                                                                   
     

     

                                                               
                                                          
                          
                                                              
                              
                                        
     
 
   
defmodule LSG.IRC do
  require Logger


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

    IRC.Connection.setup()
    IRC.Plugin.setup()

    # Probably just needed for migration
    #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.
    Logger.debug("IRC.after_start - initializing plugins")
    IRC.Plugin.start_all()
    Logger.debug("IRC.after_start - initializing connections")
    IRC.Connection.start_all()
    Logger.debug("IRC.after_start - ok")
  end

end