Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

start the dependency automatically #17

Open
wants to merge 3 commits into
from
Jump to file or symbol
Failed to load files and symbols.
+14 −14
Split
View
@@ -1,6 +1,6 @@
{erl_opts, [debug_info]}. %, fail_on_warning]}.
-{require_otp_vsn, "R14"}.
+{require_otp_vsn, "R15"}.
{deps_dir, ["deps"]}.
View
@@ -1,19 +1,19 @@
-module(bigwig).
-export([start/0, stop/0]).
-ensure_started(App) ->
- case application:start(App) of
- ok ->
- ok;
- {error, {already_started, App}} ->
- ok
- end.
-
start() ->
- ensure_started(crypto),
- ensure_started(sasl),
- ensure_started(cowboy),
- application:start(bigwig).
-
+ start(bigwig).
stop() ->
application:stop(bigwig).
+start(App) ->
+ start_ok(App, application:start(App, permanent)).
+
+start_ok(_App, ok) ->
+ ok;
+start_ok(_App, {error, {already_started, _App}}) ->
+ ok;
+start_ok(App, {error, {not_started, Dep}}) ->
+ ok = start(Dep),
+ start(App);
+start_ok(_App, {error, Reason}) ->
+ erlang:error({app_start_failed, Reason}).