aboutsummaryrefslogblamecommitdiff
path: root/lib/application.ex
blob: 3e3a6acffd67d89d78b6ea0fe4bcc2e62503bceb (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

    {listen_port, _} = Integer.parse ((System.get_env "PORT") || "4044")

    # Define workers and child supervisors to be supervised
    children = [
      Shard.Identity,
      { DynamicSupervisor, strategy: :one_for_one, name: Shard.DynamicSupervisor },
      
      # Networking
      { SNet.TCPServer, listen_port },

      # Applications & data store
      { Shard.Manager, listen_port },
    ]

    # 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