[erlang-questions] supervising applications

Moe Aboulkheir <>
Wed Sep 20 02:29:47 CEST 2006



On Tue, 19 Sep 2006 17:12:10 -0700, Bob Ippolito <> wrote:
>On 9/19/06, Moe Aboulkheir <> wrote:
>>Hi,
>>
>>I'm very new to this.  I've written a trivial Erlang application, and i am 
>>trying to write a second one which provides a superset of the functionality 
>>of the first.  The supervisor that is started from start/2 in the second 
>>application tries to start the first application by including an entry for 
>>it in the list returned from init/1.  I tried the following two methods, 
>>but neither works:
>>
>>1) Having StartFunc (in the init/1 term) as {application, start, [app1]}. 
>>This doesn't work because application:start/1 returns ok instead of {ok, 
>>Pid} like the supervisor interface wants.  Ideally i'd have liked to be 
>>able to this, because app1:start/2 passes some stuff from its environment 
>>as the argument to app1_supervisor:start_link/1, but i guess i could move 
>>that stuff further into app1, though i saw an example that did the setup 
>>here, and it makes sense to me
>>
>>2) Having StartFunc as {app1_supervisor, start_link, ...}.  This doesn't 
>>work because some code inside app1 depends on things in the environment of 
>>app1's .app file - things that don't seem to be available when i start it 
>>like this.  Again, i could move these variables into app2's environment, 
>>but i'd like to be able to use app1 without using app2, and would rather 
>>not maintain the information in two places.
>>
>>Any ideas?
>
>Isn't this what you'd use the {applications, [app1, ...]} list for in
>the .app file?
>
>-bob
>

I tried that before (putting app1 in app2's "applications" list and starting its supervisor directly from app2), but I get an {error,{not_started,app1}} when starting app2.  the docs say: 

"""
[when starting an application]
The application controller checks the value of the application specification key applications, to ensure that all applications that should be started before this application are running. If not, {error,{not_started,App}} is returned, where App is the name of the missing application.
"""

Which seems to indicate that as long as app1 is in app2's applications list, it won't be possible to start it from app2's start() - and cursory examination (an erlang:display() in start()) indicates that it doesn't even get that far.

--
Moe Aboulkheir



More information about the erlang-questions mailing list