[erlang-questions] initializing library applications without processes

karol skocik <>
Sun Apr 4 19:21:54 CEST 2010

  well, I am refactoring some of my older code dealing with paypal
payments and amazon (ec2, s3) stuff.
They are basically libraries - they don't execute any activity, and
there is nothing I want them to do except being functioning when some
other module uses their API.
To be functioning means executing in the context of the caller of the
function (block caller until the library function finishes), but at
the same time have access to some state related to what they do -
typically configuration (authorization keys, shopping list, ...).
Starting the application should ensure that the state is
loaded/initialized ok - I want to fail at application:start()'s time,
not later finding out initialization wasn't correct, or rely on manual
app:start() invocation. It should play nicely with what's written in
.rel file.
Ulf's solution was exactly what I needed, since I need the supervisor
process anyway (to be a owner of ETS table).

On Sun, Apr 4, 2010 at 6:49 PM, Eric Merritt <> wrote:
> Karol,
> When I hear a question like this I want to step back and ask about the
> bigger picture. There are a bunch of ways to do this, bob and ulf have
> gone into some detail on those. Those address the question your asking
> but not the higher level issue that this is a symptom of. If you can
> would you mind stepping back and describing what it is you are trying
> to do at a higher level? I suspect that the best answer will be a
> solution to that, not an answer to the specific question you are
> asking here.
> Eric
> On Sat, Apr 3, 2010 at 12:17 PM, karol skocik <> wrote:
>> Hi,
>>  sometimes, I just need a library "application" without processes,
>> which works with some state in ETS. To function properly,
>> they have to make the ETS table and populate it with values
>> from config files. When that step is done, there is nothing left to do
>> for processes, they would just serve as a useless proxy for
>> querying the ETS table, and that's not needed when you can (in some contexts)
>> access the table directly.
>> I like the mechanism of applications and their dependency solving,
>> and I would ideally do application:start(my_app_with_ets_initialised)
>> but that won't do, since {ok, SupPid} is expected as a result.
>> But I don't want to start any processes, I just want to ensure that
>> application_master:init/4 calls my "start" function,
>> and declare application as "running" when 'ok' is returned
>> or fail otherwise (unless it's {ok, SupPid} - as it is now).
>> Currently, when we have library application, application:start(...)
>> does not call anything since 'mod' is not specified in .app file.
>> Could it be changed, and application behaviour would just call
>> start/2 and stop/1 as usual, but start the SupPid optionally when it's supplied?
>> Or - alternatively - is there any way how to ensure that some init
>> function is done
>> fitting nicely with application dependencies as declared in .rel file?
>> Thanks,
>>  Karol
>> ________________________________________________________________
>> erlang-questions (at) erlang.org mailing list.
>> See http://www.erlang.org/faq.html
>> To unsubscribe; mailto:

More information about the erlang-questions mailing list