A method to start Erlang applications in standalone (daemon) __erlang

Source: Internet
Author: User

http://cryolite.iteye.com/blog/383927

Erlang defaults to run with a terminal, in the development process can be very convenient to check the bug, but after the development is completed, should run the service in the background.

-noshell (this parameter closes the terminal but still does not run in the background and prints directly to the current screen with output)

-noinput to prohibit the input under the terminal

-hidden Hide Run

-detached background operation

In fact, the best use is-detached, if you add this parameter to the startup script, the program will immediately run into the background, you can transfer it to the foreground through the process number, after you join this parameter to run the server, look at the currently running program, you will find that this parameter is automatically decomposed into-noshell and- Noinput, so after joining-detached, you don't need to add these two parameters-------

Start a Erlang virtual machine like a normal Java application, and the program runs on a virtual machine without an interactive interface.

One approach is to start with-detached parameters, so the Erlang virtual machine enters the so-called detached mode, in detached mode, Erlang runs silently behind, there is no common interface between the interactive terminal.

Example: Starting a My_app application in detached mode
Shell Code erl-detached-name Foo@192.168.1.103-setcookie abc-s My_app
My_app, like a normal daemon application, runs in the back.

But what to do when you want to control the Erlang virtual machine launched in detached mode, such as exiting the application, or viewing the Erlang application status.

The way to connect Erlang nodes in detached mode is as I know two of them:

1. Log in with the remote Shell JCL, which is described in the 6.7.3 section of programming Erlang, which is simply the shell interface after ctrl+g. The specific methods are:
i) Start a Erlang node:
Shell Code erl-name Bar@192.168.1.103-setcookie ABC
II Ctrl+g into the shell JCL and then remotely connect Erlang in detached mode:
Erlang Shell Code--> R ' foo@192.168.1.103 '--> C Eshell V5.7.1 (abort with ^g) (foo@192.168.1.103) 1>
We can control Erlang in detached mode.

2. Using the Erl-remsh parameter
Shell Code erl-name BAR@192.168.1.103-REMSH Foo@192.168.1.103-setcookie ABC
But I don't know how to revert to the original detached mode after attach.


Personally think the shell JCL Way is better, if there are more than one detached mode of Erlang node (whether or not remote), can be a erlang shell control, a little screen feeling, hehe.

The detached pattern is more in line with our usual Erlang boot methods. Another practical way to access the Erlang console in Mryufeng is a good one, but I don't know if it can be accessed remotely.

Well, write it down first.

Note:
Booting with-detached parameters may be equivalent to booting with both-noshell and-noinput parameters, using the
Linux Shell Code Ps-ef|grep Beam
When you view the-detached-initiated Erlang process, you will find that the-noshell-noinput parameters are included.


Resources
1. Detached mode
2. Erl
3. How to start a Erlang applications from the command line non-interactively?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.