[erlang-questions] Why application:start can not accept any args?
Nuku Ameyibor
nayibor@REDACTED
Wed Jul 15 12:36:17 CEST 2015
application:start/1,2
<http://www.erlang.org/doc/man/application.html#start-2> is intended for
starting applications not loading configurations .
it checks that all included applications are loaded b5 starting,plus some
other stuff etc...
there are multiple ways to pass arguments to an erlang application .some
override others etc...
have a look at http://www.erlang.org/doc/man/config.html .
it will give u different ways to do that .
On Mon, Jul 13, 2015 at 11:54 PM, Lihe Wang <wanglihe.programmer@REDACTED>
wrote:
> Thank you Nuku. Yes it is a solution pass args to a application, but why
> not pass args directly by application:start(mycode1, Arg1)? Why otp design
> a api this way? And application behaviour's callback function start, it
> needs Args. It is seems like that something forgotten or something wrong.
> In application.erl or somewhere, it generate a atom 'normal' and blank list
> [], then passes them to mycode1:start(Type, Args). Why?
>
> 2015-07-13 18:39 GMT+08:00 Nuku Ameyibor <nayibor@REDACTED>:
>
>> u can add environmental variables for your application in your .app
>> file .
>> there is a tuple with a key env which u can use to add environmental
>> variables to your application which you can then access from your
>> application
>> eg .
>> {application, test,
>> [{vsn, "1.0.0"},
>> {description, "testing"},
>> {modules, [test, test_sup,test_start]},
>> {applications, [stdlib, kernel, crypto]},
>> {registered, [test,test_sup]},
>> {mod, {test, []}},
>> {env,
>> [
>> {env1,b},
>> {env2,a},
>> {env3,c}
>> ]
>> }
>> ]}.
>>
>> you can access them like so
>> {ok, Env} = application:get_env(env1), etc..
>>
>> there is also a set_env/3 ,set_env/4 which can be used to change
>> environmental variables during run-time
>>
>>
>> On Sun, Jul 12, 2015 at 1:19 PM, Lihe Wang <wanglihe.programmer@REDACTED
>> > wrote:
>>
>>> Can any one give the explain about OTP? The application behaviour's call
>>> back "start" need args, but when I want start my code as a real
>>> application, I only can write "applicaion:start(mycode)", and can not pass
>>> any args to mycode. Why otp design like this? When I want start a
>>> application as background service from escript, for example:
>>>
>>> main([Arg1, Arg2, Arg3]) ->
>>> application:start(mycode1), %%with Arg1
>>> application:start(mycode2), %%with Arg2
>>> workcode(Arg3). %%workcode (escript) will run as a daemon, and need
>>> service supplied by mycode1 and mycode2.
>>>
>>> What is the right way to write these code?
>>>
>>>
>>>
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED
>>> http://erlang.org/mailman/listinfo/erlang-questions
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150715/9ad95fe6/attachment.htm>
More information about the erlang-questions
mailing list