Go Linux Background Process management tool: Supervisor

Source: Internet
Author: User

from:http://www.liaoxuefeng.com/article/0013738926914703df5e93589a14c19807f0e285194fe84000

Linux Background Process management tool: Supervisor

Liaoche/Programming/ 2011-4-5 13:09/read: 7211

Linux background process has several methods, such as Nohup,screen, but, if it is a service program, to reliably run in the background, we need to make it daemon, it is best to monitor the status of the process, at the end of the accident can automatically restart.

Supervisor is a set of common process management programs developed with Python that can turn a normal command-line process into a background daemon and monitor the status of the process, which can be restarted automatically when the exception exits.

Installing Supervisor

Debian/ubuntu can be installed directly via apt:

# apt-get install supervisor

Then, write a configuration file for our own development application and let supervisor manage it. Each process configuration file can be split separately, placed in the/etc/supervisor/conf.d/directory, with. conf as the extension, for example, app.conf defines a gunicorn process:

[program:app]command=/usr/bin/gunicorn -w 1 wsgiapp:applicationdirectory=/srv/wwwuser=www-data

Where the process app is defined in [Program:app], command is the commands, directory is the current directory of the process, and user is the identity of the process running.

Restart supervisor, let the configuration file take effect, and then run the command supervisorctl start the process:

start app

To stop a process:

# supervisorctl stop app

If you want to use a variable on the command line, you need to write a shell script yourself first:

#!/bin/sh/usr/bin/gunicorn -w `grep -c ^processor /proc/cpuinfo` wsgiapp:application

Then, add the X permission, and then point the command to the shell script.

Supervisor also has a number of options, the default AutoRestart is unexpected (exception exit), refer to Supervisor documentation for details.

Go Linux Background Process management tool: Supervisor

Related Article

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.