Supervisor Process Management Tools

Source: Internet
Author: User

Supervisor1. Introduction

Supervisor is a process management tool written in Python that makes it easy to start, restart, and close processes (not just the Python process). In addition to controlling a single process, you can start and close multiple processes at the same time, such as unfortunate server problems that cause all applications to be killed, and you can start all applications with supervisor at the same time instead of one by one.

2. Installation

The following two methods of installation are available:

    • # PIP Install Supervisor

    • # tar ZXVF supervisor-3.1.3.tar.gz
      # CD Supervisor
      # python setup.py Install

3. Configuration
  • Build configuration file
    # echosupervisordconf >/etc/supervisord.conf

  • Change the configuration file, here to Tomcat,ismsrvDebug as an example
    # vim/etc/supervisord.conf
    # program Configuration
    [Program:tomcat]
    directory =/opt/tomcat
    App/bin; Startup directory of the program
    Command = SH startup.sh; Start command, you can see the same as the command that is started manually on the command line
    Autostart = true; It starts automatically when the Supervisord is started.
    Startsecs = 10; No exception exits after 10 seconds of startup, as if it had started normally.
    AutoRestart = true; Automatic restart after program exits unexpectedly
    Startretries = 3; Startup failed auto Retry number, default is 3
    user = root; With which user to start
    redirectstderr = true; redirect stderr to stdout, default false
    StdOutlogfilemaxbytes = 20MB; StdOut log file size, default 20MB
    StdOut
    LogFilebackups = 20; StdOut number of log file backups
    StdOut
    logfile =/opt/supervisor-3.1.3/super.log; StdOut log file, be aware that it does not start properly when the specified directory does not exist, so you need to create the directory manually (Supervisord automatically creates the log file)
    ; environment = Pythonpath= $PYTHONPATH:/opt/mypy

  • Change the Tomcat configuration
    Processes that use Supervisord monitoring management must start with Nodaemon, which is not a daemon daemon. The startup.sh script for Tomcat is daemon, so the configuration file needs to be changed.
    # vim/opt/tomcat_app/bin/startup.sh
    (change start to run)
    Exec "$PRGDIR"/"$EXECUTABLE" Run "[email protected]"

4. Start

# supervisord-c/etc/supervisord.conf Start Supervisor
# Supervisorctl Status View state
# supervisorctl Reload Reload config file
# Supervisorctl Start Tomcat startup Project
# Supervisorctl Stop Tomcat Close Project
# supervisorctl Restart Tomcat Restart Project

5. Verification

# Ps-ef | grep Tomcat view, Tomcat not started
# Launch Supervisor # Ps-ef | When grep tomcat supervisor starts, Tomcat will also start
# Simulate kill Tomcat process.
# Ps-ef | grep Tomcat View will find that Tomcat is automatically pulled up and the process number has changed

6. Note

It is possible to write all the configuration items into the supervisord.conf file, but it is not recommended to do so, but to write different programs (groups) into different configuration files by using the Include method. We created a new directory/etc/supervisor/for these configuration files.

# vim/etc/supervisord.conf
[include]
Files =/etc/supervisor/*.conf

Create Profile Management program.
A configuration file requires at least one configuration of the [program:x] section to tell Supervisord that the process needs to be managed.


Supervisor Process Management Tools

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.