[Linux] PHP Programmers play Linux series-using supervisor to implement Daemons

Source: Internet
Author: User

1.PHP programmer to play Linux series-How to install using CentOS

2.PHP programmer to play Linux series-LNMP Environment building

3.PHP Programmer play Linux series-Build FTP code development environment

4.PHP Programmer play Linux series-backup restore MySQL

5.PHP Programmer play Linux series-automatic backup with SVN

6.PHP Programmer Topsy Linux series-linux and Windows Installer Nginx

7.PHP Programmer play Linux series-nginx Beginner Guide

8.PHP programmer playing with HTTPS in Linux series-nginx

The first problem is that when you deploy Nodejs's blog, I put the command to execute Nodejs in the background, using the Add & and Nohup commands

such as: Nodejs Index.js & or Nohup Nodejs index.js &

& This use is when exiting the terminal session will stop, nohup This command can theoretically be executed in the background, but when there are some exceptions, will still exit.

Basic concepts of processes

A process is the process of executing a program. The Ppid of the Unix system's ancestor kernel process is 0, for example: The PID of the init process is 1,ppid 0; the other processes are forked from the init process, and the process tree is visible using the pstree command.

Test use & Implement a background process, and the background process back to the foreground, the following is to put the process into the background, [1] This is the job number

The background process is re-forwarded to the foreground, and the%1 number is the job number above

FG%1

How to use the Nohup command

The Nohup command, which is a command that causes the process to ignore the Sighup hang (hangup) signal, is tested as follows:

Nohup ping baidu.com > Xx.txt &

The process signals are as follows:

SIGHUP suspend (hangup) SIGINT interrupt, when the user from the keyboard to press the ^C or ^break key when the Sigquit exit, when the user press the QUIT key from the keyboard Sigill illegal instructions SIGTRAP tracking traps (trace trap), Start process, trace Code execution sigiot iot Directive sigemt EMT Instruction SIGFPE floating-point arithmetic overflow SIGKILL kill, terminate process Sigbus bus error one SIGSEGV segment violation (segmentation
   
    violation), the process attempts to access a location other than its virtual address space of the Sigsys system call in the wrong parameter, such as the system call number illegal sigpipe write data to a non-read pipeline sigalrm alarm. This signal is sent when a process wants to receive a signal after a certain time. SIGTERM software termination (software  termination) SIGUSR1 user-defined signal 117 SIGUSR2 user-defined signal 218 SIGCLD a child process dead 19 SIGPWR Power failure
   

  

Implementing Daemons using Supervisor

The daemon is a process that has been running for a long period of time. Using supervisor, you can implement such a process, which is automatically restarted when it is killed.

#安装supervisoryum Install Supervisor

Configure the configuration file (/etc/supervisord.conf):

Program:nodejsblog here: The back is a name, you can start casually
command= here is the command to execute
User= here is the execution user

[Program:nodejsblog]command=/usr/bin/nodejs/var/www/html/nblog index.js User=root

Open Supervisord-c/etc/supervisord.conf

At this point the Nodejs daemon will also be able to check with the PS command as it is started, and will automatically restart when you kill the process.

For example, I test the deployment of the Nodejs site in this example http://nblog.qingguow.cn

Blog posts related to this:

[Nodejs] Nodejs Development Personal Blog (vii) Backstage loginTaoshan 2016-03-17 23:01 read: 1002 comments: 0[Nodejs] Nodejs Development Personal Blog (vi) data pagingTaoshan 2016-03-13 22:59 read: 348 comments: 0[Nodejs] Nodejs Development Personal Blog (v) assigning dataTaoshan 2016-03-12 00:16 read: 88 comments: 0[Nodejs] Nodejs Development Personal Blog (iv) data modelTaoshan 2016-03-09 22:51 read: 98 comments: 0[Nodejs] Nodejs Development Personal Blog (iii) loading pageTaoshan 2016-03-08 22:38 read: 114 comments: 0[Nodejs] Nodejs Development Personal Blog (ii) entry fileTaoshan 2016-03-06 22:37 read: 218 comments: 0[Nodejs] Nodejs Development Personal Blog (i) preparatory workTaoshan 2016-03-05 22:05 read: 207 comments: 0

  

[Linux] PHP Programmers play Linux series-using supervisor to implement Daemons

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.