|
| 1 | +%% @author author <author@example.com> |
| 2 | +%% @copyright YYYY author. |
| 3 | + |
| 4 | +%% @doc fileserver startup code |
| 5 | + |
| 6 | +-module(fileserver). |
| 7 | +-author('author <author@example.com>'). |
| 8 | +-export([start/0, start_link/0, stop/0]). |
| 9 | + |
| 10 | +ensure_started(App) -> |
| 11 | + case application:start(App) of |
| 12 | + ok -> |
| 13 | + ok; |
| 14 | + {error, {already_started, App}} -> |
| 15 | + ok |
| 16 | + end. |
| 17 | + |
| 18 | +%% @spec start_link() -> {ok,Pid::pid()} |
| 19 | +%% @doc Starts the app for inclusion in a supervisor tree |
| 20 | +start_link() -> |
| 21 | + ensure_started(inets), |
| 22 | + ensure_started(crypto), |
| 23 | + ensure_started(mochiweb), |
| 24 | + application:set_env(webmachine, webmachine_logger_module, |
| 25 | + webmachine_logger), |
| 26 | + ensure_started(webmachine), |
| 27 | + fileserver_sup:start_link(). |
| 28 | + |
| 29 | +%% @spec start() -> ok |
| 30 | +%% @doc Start the fileserver server. |
| 31 | +start() -> |
| 32 | + ensure_started(inets), |
| 33 | + ensure_started(crypto), |
| 34 | + ensure_started(mochiweb), |
| 35 | + application:set_env(webmachine, webmachine_logger_module, |
| 36 | + webmachine_logger), |
| 37 | + ensure_started(webmachine), |
| 38 | + application:start(fileserver). |
| 39 | + |
| 40 | +%% @spec stop() -> ok |
| 41 | +%% @doc Stop the fileserver server. |
| 42 | +stop() -> |
| 43 | + Res = application:stop(fileserver), |
| 44 | + application:stop(webmachine), |
| 45 | + application:stop(mochiweb), |
| 46 | + application:stop(crypto), |
| 47 | + application:stop(inets), |
| 48 | + Res. |
0 commit comments