Added boilerplate code to load the core modules as an app.
authorMatt Mullins <mmullins@mmlx.us>
Sat, 21 May 2011 22:53:59 +0000 (17:53 -0500)
committerMatt Mullins <mmullins@mmlx.us>
Sat, 21 May 2011 22:53:59 +0000 (17:53 -0500)
core/core.app [new file with mode: 0644]
core/core_app.erl [new file with mode: 0644]
core/core_sup.erl [new file with mode: 0644]

diff --git a/core/core.app b/core/core.app
new file mode 100644 (file)
index 0000000..60f9022
--- /dev/null
@@ -0,0 +1,10 @@
+{application, core,
+ [{description, "IRC bot core functionality"},
+  {vsn, "1"},
+  {modules, [core_app, core_sup, config]},
+  {registered, [config]},
+  {applications, []}, % also depends on kernel, stdlib
+  {mod, {core_app, none}}
+ ]}.
+
+
diff --git a/core/core_app.erl b/core/core_app.erl
new file mode 100644 (file)
index 0000000..606a623
--- /dev/null
@@ -0,0 +1,9 @@
+%% @doc Application callback for the core modules.
+
+-module(core_app).
+-behavior(application).
+
+-export([start/2]).
+
+start(normal, _) ->
+    core_sup:start_link().
diff --git a/core/core_sup.erl b/core/core_sup.erl
new file mode 100644 (file)
index 0000000..8f03665
--- /dev/null
@@ -0,0 +1,27 @@
+%% @doc Top-level supervisor for the core app.
+
+-module(core_sup).
+-behavior(supervisor).
+
+% Public-facing functions
+-export([start_link/0]).
+
+% Callback for supervisor
+-export([init/1]).
+
+% Public-facing function
+%% @doc Start the supervisor and link to the calling process
+start_link() ->
+    supervisor:start_link(?MODULE, []).
+
+%% @doc Spawn the configuration file process.  We don't have any other "core"
+%% processes at this time.
+init(_) ->
+    ConfigChild = {config, % ID
+                   {config, start_link, []}, % child MFA
+                   permanent, % Restart strategy
+                   brutal_kill, % Shutdown strategy
+                   worker, % Type
+                   [config] }, % modules
+    RestartStrategy = {one_for_one, 5, 60},
+    {ok, {RestartStrategy, [ConfigChild]}}.