running mnesia node with its business logic as an OS deamon

121 Views Asked by At

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

$erl -name [email protected] -mnesia dir '"/home/app/logic/database"' -setcookie  cookie

[email protected]> cd("/home/app/logic"). 

[email protected]> c(module1).

[email protected]> c(module2).

[email protected]> c(module3).

[email protected]> application:start(mnesia).

[email protected]>

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.

3

There are 3 best solutions below

3
On BEST ANSWER

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

0
On

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("[email protected]",application,stop,[mnesia]).

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

1
On

This worked perfectly well.

$erl -name [email protected] -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 [email protected] -pa /home/app/logic -mnesia dir '"/home/app/logic/database"' -eval "application:stop(mnesia)" -setcookie cookie -detached