2010-02-25 17:45:11 +00:00
|
|
|
%% @author author <author@example.com>
|
|
|
|
%% @copyright YYYY author.
|
|
|
|
|
|
|
|
%% @doc TEMPLATE.
|
|
|
|
|
|
|
|
-module(flukso).
|
|
|
|
-author('author <author@example.com>').
|
|
|
|
-export([start/0, start_link/0, stop/0]).
|
|
|
|
|
|
|
|
ensure_started(App) ->
|
|
|
|
case application:start(App) of
|
|
|
|
ok ->
|
|
|
|
ok;
|
|
|
|
{error, {already_started, App}} ->
|
|
|
|
ok
|
|
|
|
end.
|
|
|
|
|
2010-03-14 20:31:10 +00:00
|
|
|
mysql_prepare() ->
|
|
|
|
mysql:prepare(permissions, <<"SELECT permissions FROM logger_tokens WHERE meter = ? AND token = ?">>).
|
|
|
|
|
2010-02-25 17:45:11 +00:00
|
|
|
%% @spec start_link() -> {ok,Pid::pid()}
|
|
|
|
%% @doc Starts the app for inclusion in a supervisor tree
|
|
|
|
start_link() ->
|
|
|
|
flukso_deps:ensure(),
|
|
|
|
ensure_started(crypto),
|
2010-03-13 13:00:51 +00:00
|
|
|
ensure_started(erlrrd),
|
|
|
|
ensure_started(mysql),
|
2010-03-14 20:31:10 +00:00
|
|
|
mysql_prepare(),
|
2010-02-25 17:45:11 +00:00
|
|
|
ensure_started(webmachine),
|
|
|
|
flukso_sup:start_link().
|
|
|
|
|
|
|
|
%% @spec start() -> ok
|
|
|
|
%% @doc Start the flukso server.
|
|
|
|
start() ->
|
|
|
|
flukso_deps:ensure(),
|
|
|
|
ensure_started(crypto),
|
2010-03-13 13:00:51 +00:00
|
|
|
ensure_started(erlrrd),
|
|
|
|
ensure_started(mysql),
|
2010-03-14 20:31:10 +00:00
|
|
|
mysql_prepare(),
|
2010-02-25 17:45:11 +00:00
|
|
|
ensure_started(webmachine),
|
2010-03-13 13:00:51 +00:00
|
|
|
application:start(flukso).
|
2010-02-25 17:45:11 +00:00
|
|
|
|
|
|
|
%% @spec stop() -> ok
|
|
|
|
%% @doc Stop the flukso server.
|
|
|
|
stop() ->
|
|
|
|
Res = application:stop(flukso),
|
|
|
|
application:stop(webmachine),
|
2010-03-13 13:00:51 +00:00
|
|
|
application:stop(mysql),
|
|
|
|
application:stop(erlrrd),
|
2010-02-25 17:45:11 +00:00
|
|
|
application:stop(crypto),
|
|
|
|
Res.
|