[erlang-questions] How to start an erlang applications from the command line non-interactively?

Nick Gerakines nick@REDACTED
Mon May 5 20:42:00 CEST 2008


There are a few ways to do what you want. Both of them involve using
the -detached erl arg.

If you are using an application you'll want to create a boot script
using the .app and .rel file. I consider this crucial for deploying
applications.

erl -name myapp@`hostname` -noshell -detached -setcookie myappcookie -boot myapp

If you've got a simple MFA that you want to run in the background you
can do it with -s.

Consider the module foo that exports the method bar:

erl -name fooapp@`hostname` -noshell -detached +W w +A 1 +Ktrue
-setcookie foocookie -s foo bar

Just keep in mind that to connect to detached erlang nodes, you'll
need to be sure your cookies match. Otherwise you should be good to
go.

I tend to do something like:

$ erl -name fooapp_ctl@`hostname` -setcookie foocookie

Eshell V5.6.1  (abort with ^G)
(fooapp_ctl@REDACTED)1> ^G
User switch command
 --> r'fooapp@REDACTED'
 --> c
Eshell V5.6.1  (abort with ^G)
(fooapp@REDACTED)1>

# Nick Gerakines

2008/5/5 Jarrod Roberson <jarrod@REDACTED>:
> I have the Pragmatic Programmers book, and have searched Google and can't
> figure out how to start my program from the command line in _non_
> interactive mode.
> I am using windows at the moment as well, but I can translate from *nix
> instructions.
>
> I have tried the -s and -run options to erl but they both leave me in an
> interactive erlang shell.
>
> I want the interpreter to start up and run my app and detach from the shell
> "stand alone".
>
> _______________________________________________
>  erlang-questions mailing list
>  erlang-questions@REDACTED
>  http://www.erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list