Process Management Tool Supervisor installation and use tutorial

Source: Internet
Author: User

Supervisor is a process management tool written in Python that is used to start, restart, and close processes. The following article mainly to introduce the python implementation of the Process Management tool supervisor installation and use of relevant information, the need for friends can reference, the following to see together.

  Objective

  In a distributed environment, it may be necessary to start and stop multiple processes on each machine, using a command-line approach to start and stop manually, and it is inconvenient to look at the status of each process. It would be convenient to have a single tool that enables simple and efficient centralized management of multiple processes on each machine. So Supervisord tools came into being. Tools similar to Supervisord include Monit,daemontools and Runit. The following words do not say much, come together to see the detailed introduction.

  Installation

Supervisord is a service monitor running in a Python environment, so you must have a Python environment before you install Supervisord.

Yum Install python-setuptoolseasy_install Supervisor

If the installation succeeds, type echo_supervisord_conf :, a superviscord_conf configuration template is displayed.

  Detailed configuration file

[Unix_http_server]file=/tmp/Supervisor.sock; UNIX socket file, SUPERVISORCTL will be used; chmod=0700; Socket file mode, default is 0700; Chown=nobody:nogroup; socket file owner, format: Uid:gid; [Inet_http_server]; HTTP server, providing Web management interface; Port=127.0.0.1:9001 ; Web Management background Run IP and port, if open to public network, need to pay attention to security; Username=user; Login admin background username; password=123; login admin background password [supervisord]logfile=/tmp/supervisord.log; Log file, default is$CWD/supervisord.loglogfile_maxbytes=50MB; log file size, exceeding rotate, default 50mblogfile_backups=10; Log files retain the number of backups by default 10loglevel=info, log level, default info, others: Debug,warn,tracepidfile=/tmp/supervisord.pid; PID file Nodaemon=false; If it is started in the foreground, the default isfalse, which is to start the Minfds in a daemon way=1024; The minimum value of the file descriptor that can be opened, default 1024Minprocs=200; Minimum number of processes that can be opened, default 200; The below section must remaininchThe config file forRPC; (Supervisorctl/Web Interface) to work, additional interfaces may; Added by defining theminchseparate rpcinterface:sections[rpcinterface:supervisor]supervisor.rpcinterface_factory=Supervisor.rpcinterface:make_main_rpcinterface[supervisorctl]serverurl=unix:///tmp/Supervisor.sock; Through the UNIX socket connection Supervisord, the path is consistent with the file of the unix_http_server part; ServerURL=http://127.0.0.1:9001; connect to Supervisord via HTTP; include additional configuration files [Include]files= Relative/directory/*.ini; It could be *.conf or *.ini.

  Process program Configuration

[Program:usercenter]directory=/home/leon/projects/usercenter; start directory command for the program= Gunicorn-c gunicorn.py wsgi:app; Start command, you can see that the command started manually at the command line is the same as Autostart=trueSupervisord also starts automatically when the Startsecs is started.= 5; Start 5seconds after no abnormal exit, as if it had started normally autorestart=true, the program automatically restarts after exiting unexpectedly startretries= 3; Startup failed auto Retry number, default is 3User=Leon; with which user to start Redirect_stderr=true; REDIRECT stderr to stdout, defaultfalsestdout_logfile_maxbytes=20MB; stdout log file size, default 50mbstdout_logfile_backups= 20; stdout log file backup number; StdOut log file, you need to be aware that when the specified directory does not exist, it will not start properly, so you need to create the directory manually (Supervisord automatically creates the log file) Stdout_logfile=/data/logs/Usercenter_stdout.log; Environment can be used to add the required environment variables, a common use is to modify the PYTHONPATH; Environment=pythonpath=$PYTHONPATH:/path/to/somewhere

To add a process configuration to the supervisord.conf file

It is recommended that each process configuration be placed in a separate file and then referenced through the [include] configuration item

=/etc/supervisor/*.conf

Supervisor Service startup

Run command

Supervisord-c/etc/supervisord.conf

Supervisor Service Client Management

You can use Supervisord's command-line client management tool SUPERVISORCTL to manage processes.

Supervisorctl statussupervisorctl Stop usercentersupervisorctl start usercentersupervisorctl restart Usercentersupervisorctl rereadsupervisorctl Update

Supervisor Web Management Interface

; [Inet_http_server]; HTTP server, provide Web management interface; Port=127.0.0.1:9001 ; Web Management background Run IP and port, if open to public network, need to pay attention to security; Username=user; login admin background username; password= 123; Password for login admin background

Enter http://127.0.0.1:9001 in the browser to enter the Web management interface

Original link: https://www.chen-hao.com.cn/posts/6255/

Process Management Tool Supervisor installation and use tutorial

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.