--- /dev/null
+{application, irc,
+ [{description, "IRC protocol application"},
+ {vsn, 1},
+ {modules, [irc_app, irc_sup, irc_net_sup, irc_conn]},
+ {registered, [irc_sup]},
+ {applications, [core]},
+ {mod, {irc_app, []}}
+ ]}.
--- /dev/null
+%% @doc Top-level supervisor for the IRC application.
+-module(irc_sup).
+-behavior(supervisor).
+
+%% Public functions
+-export([start_link/0]).
+
+%% Callbacks for supervisor behavior
+-export([init/1]).
+-compile(export_all).
+
+start_link() ->
+ supervisor:start_link({local, ?MODULE}, ?MODULE, []).
+
+init(_) ->
+ IrcConfigs = config:get_config(irc),
+ Children = lists:map(fun config_to_childspec/1, IrcConfigs),
+ Restart = {one_for_one, 5, 60},
+ {ok, {Restart, Children}}.
+
+config_to_childspec({Instance, Config}) ->
+ {instance, % child's name
+ {irc_net_sup, start_link, [Instance, Config]}, % MFA
+ permanent, % Restart
+ 5, % shutdown [timeout of 5 seconds]
+ supervisor,
+ [irc_net_sup]
+ }.