Erlang release app passing command line parameters

Hello.

I’ve searched now a bit for this in various places. Supposedly it should work with escript.
My rebar3 project, when I tell it to create a ‘release’, it seems to create some scripts that allow to start the application. In particular with specifying {extended_start_script, true} I get many options. But it’s not clear to me what I have to do to allow passing arbitrary parameters and make the application start as daemon, since it is a server application.
Any advice would be welcome.

Manfred

3 Likes

Hello Manfred,

I am not an Erlang Guru but for me it works for LINUX as follows:

Lets assume the name of the project is: wf
rebar3 as prod release
is generating a shell script wf in
wf/_build/prod/rel/wf/bin

with
./wf daemon
you may start this application in the background.
If you like to start it from system V write a
a script for example
wfstart

in

/etc/init.d

This script may contain beneath others:

export RUN_ERL_LOG_GENERATIONS=99
export RUN_ERL_LOG_MAXSIZE=2000000
/srv/www/cgi-bin-wf/wf/_build/prod/rel/wf/bin/wf daemon

All this environment optional variables you may find at:
https://www.erlang.org/doc/man/run_erl.html

Finally you must link the
the init.d script to the runlevel subdirectories
/etc/rc3.d

Best with
update-rc.d

Of course you may use system.d, but I don’t understand it.

If you rapplicateion is finally running you may connect to shell of the application, for example
to reload a module
l(module).
etc. with
to_erl /tmp/erl_pipes/wf@x800/erlang.pipe.1

where x800 is the name of your machine.

As said above, that maybe a dirty hack, but for me it works.
Markus

3 Likes