diff options
Diffstat (limited to 'server/src/jchat_sup.erl')
-rw-r--r-- | server/src/jchat_sup.erl | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/server/src/jchat_sup.erl b/server/src/jchat_sup.erl new file mode 100644 index 0000000..cbb61ba --- /dev/null +++ b/server/src/jchat_sup.erl @@ -0,0 +1,50 @@ +-module(jchat_sup). +-behaviour(supervisor). + +-export([start_link/0, init/1]). + +start_link() -> + supervisor:start_link({local, ?MODULE}, ?MODULE, []). + +init([]) -> + % Initialize database + jchat_db:init(), + + % Child specifications + Children = [ + % HTTP server + #{ + id => jchat_http, + start => {jchat_http, start_link, []}, + restart => permanent, + shutdown => 5000, + type => worker, + modules => [jchat_http] + }, + % Push notification manager + #{ + id => jchat_push, + start => {jchat_push, start_link, []}, + restart => permanent, + shutdown => 5000, + type => worker, + modules => [jchat_push] + }, + % Presence manager + #{ + id => jchat_presence, + start => {jchat_presence, start_link, []}, + restart => permanent, + shutdown => 5000, + type => worker, + modules => [jchat_presence] + } + ], + + SupFlags = #{ + strategy => one_for_one, + intensity => 10, + period => 60 + }, + + {ok, {SupFlags, Children}}. |