Question

I have developed an application which i have been running in the erlang shell by following this order.

$erl -name nodename@192.168.0.1 -mnesia dir '"/home/app/logic/database"' -setcookie  cookie

nodename@192.168.0.1> cd("/home/app/logic"). 

nodename@192.168.0.1> c(module1).

nodename@192.168.0.1> c(module2).

nodename@192.168.0.1> c(module3).

nodename@192.168.0.1> application:start(mnesia).

nodename@192.168.0.1>

Now my problem is that i want to run this application a daemon such that when i exit the erlang shell it continues running and communication with other nodes through rpc:call/4.

Was it helpful?

Solution

Kindly look at the erl command options, you should see something like -detached which would help you doing this. http://erlang.org/doc/man/erl.html

OTHER TIPS

This worked perfectly well.

$erl -name nodename@192.168.0.1 -pa /home/app/logic -mnesia dir '"/home/app/logic/database"' -eval "application:start(mnesia)" -setcookie cookie -detached 

Now I am thinking whether this works to stop mnesia safely

$erl -name nodename@192.168.0.1 -pa /home/app/logic -mnesia dir '"/home/app/logic/database"' -eval "application:stop(mnesia)" -setcookie cookie -detached 

Managing a node mnesia running as a daemon is easier to use a peer erlang node i.e a node having the same cookie i.e

$erl -name node_name@domain_name -setcookie cookie

Then send all commands to the mnesia node by rpc:call/4 for example to stop mnesia safely use this

node_name@domain_name> rpc:call("nodename@192.168.0.1",application,stop,[mnesia]).

Actually this works for all erlang nodes running as daemon whether running mnesia application of any application.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top