From 9194bf69ae80141a6d9781f5782cde218eb2b3e1 Mon Sep 17 00:00:00 2001 From: "haitao.yao" Date: Sun, 8 Jul 2012 15:18:42 +0800 Subject: [PATCH 1/3] change to r15 --- rebar.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rebar.config b/rebar.config index 757f86c..552a5aa 100644 --- a/rebar.config +++ b/rebar.config @@ -1,6 +1,6 @@ {erl_opts, [debug_info]}. %, fail_on_warning]}. -{require_otp_vsn, "R14"}. +{require_otp_vsn, "R15"}. {deps_dir, ["deps"]}. From 2aa43a5adf347903df442811ea430d08aa4b1315 Mon Sep 17 00:00:00 2001 From: "haitao.yao" Date: Sun, 8 Jul 2012 16:34:35 +0800 Subject: [PATCH 2/3] add ensure started jsx --- src/bigwig.erl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bigwig.erl b/src/bigwig.erl index 7280c79..00e9256 100644 --- a/src/bigwig.erl +++ b/src/bigwig.erl @@ -13,6 +13,7 @@ start() -> ensure_started(crypto), ensure_started(sasl), ensure_started(cowboy), + ensure_started(jsx), application:start(bigwig). stop() -> From 95891b5d176e37d22206eeb14c9681334dd61db9 Mon Sep 17 00:00:00 2001 From: "haitao.yao" Date: Sat, 15 Sep 2012 15:34:15 +0800 Subject: [PATCH 3/3] start the dependency automatically --- src/bigwig.erl | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/bigwig.erl b/src/bigwig.erl index 00e9256..4428db9 100644 --- a/src/bigwig.erl +++ b/src/bigwig.erl @@ -1,20 +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), - ensure_started(jsx), - 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}).