How to run applications on the command line as a daemon?

This was my current program.

sudo nohup erl -sname foo -pa ./ebin -run foo_supervisor shell -noshell -noinput & 

where the shell function looks something like this:

 shell() -> {ok, Pid} = supervisor:start_link({local,?MODULE}, ?MODULE, _Arg = []), unlink(Pid). 

If I do not disconnect from the shell, it immediately stops for some reason. Is there a way that I can just start my application as usual, i.e. application: start (foo). So what if I want to start sasl too? Also, where could I learn more about creating a standalone package using fittings?

+2
source share
1 answer

Foreword About your connection

In this other thread, SO @filippo explains why you need unlink when testing supervisors from the shell.

Firstly. What you need is an Erlang app .

Reading from a document:

In OTP, an application denotes a component that implements some specific functionality that can be run as a whole, and which can be reused in other systems.

Details on how to implement the Erlang application are available here . Three main things you will need to do:

Secondly. Launch SASL.

In the application resource file above, you can specify the list of applications that you want to run before your application. You will add something like:

 ... {applications, [kernel, stdlib, sasl]}, ... 

Say to run SASL.

Thirdly. Reinforcing.

Here's an introduction to Rebar that explains how to use rebar to help you in the above steps, package your new application in the Erlang release, and how to run it.

+4
source

All Articles