diff options
author | Alex Auvolat <alex@adnab.me> | 2018-09-01 16:06:23 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2018-09-01 16:06:23 +0200 |
commit | c6ec33d6e612168e14d77007915a4ea423c55a2e (patch) | |
tree | 8b5645651a0cc991b8ac9c68c388d84c8dbe73d2 /shard/lib/application.ex | |
parent | 1a0ef154a421af60f6d57dfe861dacb844a7d142 (diff) | |
download | shard-c6ec33d6e612168e14d77007915a4ea423c55a2e.tar.gz shard-c6ec33d6e612168e14d77007915a4ea423c55a2e.zip |
Move everything to subdirectory
Diffstat (limited to 'shard/lib/application.ex')
-rw-r--r-- | shard/lib/application.ex | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/shard/lib/application.ex b/shard/lib/application.ex new file mode 100644 index 0000000..3e3a6ac --- /dev/null +++ b/shard/lib/application.ex @@ -0,0 +1,33 @@ +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 |