Skip to content

Instantly share code, notes, and snippets.

@sebmaynard
Created June 6, 2013 13:54
Show Gist options
  • Save sebmaynard/5721673 to your computer and use it in GitHub Desktop.
Save sebmaynard/5721673 to your computer and use it in GitHub Desktop.
A hack to try and startup an erlang application and its dependencies. Should only really be used for lazy development/fiddling as reltool/relx/rebar will handle all this for you.
-module(module_starter_hack).
-export([try_force_start_application/1]).
try_force_start_application(App) ->
start_application_process_result(App, try_start_application(App)).
%%%%%%%%%%%%%%%
%% Helpers
try_start_application(App) ->
io:format("Trying to start ~p~n", [App]),
application:start(App).
start_application_process_result(_App, ok) ->
ok;
start_application_process_result(_App, {error, {already_started, _Dep}}) ->
ok;
start_application_process_result(App, {error, {not_started, Dep}}) ->
%% try to start the dep
start_application_process_result(App, try_start_application(Dep)),
%% now retry starting the main app
start_application_process_result(App, try_start_application(App)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment