From af70e7b3628d57d7b2b740e8238570c16065626f Mon Sep 17 00:00:00 2001 From: Matt Mullins Date: Sat, 21 May 2011 17:53:59 -0500 Subject: [PATCH] Added boilerplate code to load the core modules as an app. --- core/core.app | 10 ++++++++++ core/core_app.erl | 9 +++++++++ core/core_sup.erl | 27 +++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 core/core.app create mode 100644 core/core_app.erl create mode 100644 core/core_sup.erl diff --git a/core/core.app b/core/core.app new file mode 100644 index 0000000..60f9022 --- /dev/null +++ b/core/core.app @@ -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 index 0000000..606a623 --- /dev/null +++ b/core/core_app.erl @@ -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 index 0000000..8f03665 --- /dev/null +++ b/core/core_sup.erl @@ -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]}}. -- 2.11.0