diff options
Diffstat (limited to 'lib/application.ex')
-rw-r--r-- | lib/application.ex | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/application.ex b/lib/application.ex new file mode 100644 index 0000000..a199e6c --- /dev/null +++ b/lib/application.ex @@ -0,0 +1,33 @@ +defmodule Shard.Application do + @moduledoc """ + Documentation for Shard. + """ + + 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, + + # Networking + { DynamicSupervisor, strategy: :one_for_one, name: SNet.ConnSupervisor }, + { SNet.TCPServer, listen_port }, + + # Applications & data store + { SData.MerkleList, [&SApp.Chat.msg_cmp/2, name: SApp.Chat.Log] }, + + # Web UI + Plug.Adapters.Cowboy.child_spec(:http, SWeb.HTTPRouter, [], port: listen_port + 1000) + ] + + # 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 |