aboutsummaryrefslogblamecommitdiff
path: root/shard/lib/application.ex
blob: de9c998adc0c9659e65ead0caa33ee71e4a7854e (plain) (tree)
1
2
3
4
5
6

                              



                                                                   






                                       

                                                           
                  
                

                     
 


                                 
                         
                 

                            
                   
                                                                           

                                     







                                                                   
defmodule Shard.Application do
  @moduledoc """
  Main Shard application.

  Shard is a prototype peer-to-peer comunication platform with data
  synchronization.
  """

  use Application

  def start(_type, _args) do
    import Supervisor.Spec, warn: false

    # Define workers and child supervisors to be supervised
    children = [
      # Networking
      SNet.Addr,
      SNet.Manager,
      SNet.TCPServer,

      # Applications & data store
      Shard.Manager,

      # Keys & identities
      Shard.Keys,

      # Initialize user data
      { Task, fn ->
          Shard.Manager.find_or_start %SApp.Chat.Manifest{channel: "lobby"}
          Shard.Keys.get_any_identity
        end },
    ]

    # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
    # for other strategies and supported options
    opts = [strategy: :one_for_one, name: Shard.Supervisor]
    Supervisor.start_link(children, opts)
  end
end