We know that when Erlang Module is created, the way to make it run in the background is:

Terminal input command: erl -detached -s hello start

-s hello start runs the hello:start() function, and -detached stands for background running.

But what about when we create the Erlang Application? How to achieve background running? The above method does not work. See article: Erlang/OTP building Applications

The solution is as follows: We adopt JCL mode:

Reference article: Erlang access to the remote Shell console (please focus on the assignment JCL mode)

* * * *

First, preparation

Use distributed, Erlang nodes. The formal program runs on Linux and remotely controls Linux through Windows.

The Windows IP address is 192.168.0.189, and the node name is [email protected]

The Linux IP address is 192.168.0.127 and the node name is [email protected]

Centos7 Disable the firewall: sudo systemctl stop Firewalld. service Run the werl command on the Windows terminal. On the Linux terminal, run erl CTRL +G to enter JCL mode and q to exit JCL\

* * * *

Second, specific implementation

Linux terminal :(IP addr-192.168.0.127) daemon, Hide the Erlang shell process in a detached run a node erl – first name [email protected] – setcookie ABC – detached to check whether the Erlang process run ps – ef | The grep beam kill command is used to stop a process. Kill -9 [PID] -9 forces the process to stop immediately Windows terminal :(IP addr-192.168.0.189) werl-name [email protected] -setcookie ABC CTRL +G –> r ‘[email protected]’ –> c Then enter the terminal command application:start(tcp_server). In this way, the Erlang daemon is implemented. This is also used if the Windows node wants to switch back

Ctrl+G

–> r ‘[email protected]

–> c\

Out of use

–> q\

\

Third, knowledge extension

Note that the value of -name must be of the form xxxx@ip. XXXX is the English name, and IP must be in the form of digits and dots. If it is a valid domain name that can be resolved, it should also work, but I tried using localhost and it was not connected properly. At the same time, the IP address must be a valid ONE accessible to the client; otherwise, the connection fails.

\

Supplementary notes: If you only want to implement node interconnection access on Linux native, this is also possible: Detached erl -name [email protected] -setcookie ABC -detached erl -name [email protected] -setcookie ABC CTRL +G r ‘[email protected]’ \