Supervisor configuration Process

Source: Internet
Author: User

Supervisor configuration Process

(Transferred from https://www.izixia.cn/2016/01/03/supervisor-pei-zhi-guo-cheng/)

1. Installation
pip install supervisorWhether the test was successful after installationecho_supervisord_conf

2. Create a configuration file
Create a Directory

mkdir -m 755 -p /etc/supervisor/

mkdir -m 755 conf.d

echo_supervisord_conf > /etc/supervisor/supervisord.conf

Create a configuration file in the Conf.d folder, such as App.ini

[program:pmapp]command=python3 /home/keith/temp/app.py  autorestart=true stdout_logfile=/home/keith/temp/supervisord_stdout.log stderr_logfile=/home/keith/temp/supervisord_stderr.log [supervisord]

The contents of app.py are as follows, and the function is a record every five seconds in writing:

import timedef log(): while True: with open(‘a.txt‘,‘a‘) as f: s = ‘log:%s \n‘%time.strftime(‘%H:%M:%S‘) f.write(s) print(s) time.sleep(5)log() 

3. Add a profile to the master profile

Open the/etc/supervisor/supervisord.conf file to the last line to see

;[include];files = /relative/dictory/*.ini

Delete the semicolon here, and then add our config file /etc/supervisor/conf.d/app.ini , modified as follows

[include]files = /etc/supervisor/conf.d/*.ini /etc/supervisor/example.ini  

Multiple paths are separated by spaces.

4. Start Supervisor

supervisorThere are two commands, supervisord and supervisorctl , by supervisord Managing the startup and configuration of supervisor itself, by supervisorctl managing some of the applications that use Supervisor startup and management itself, such as our app.py here

    • Start Supervisor with Commands
supervisord -c /etc/supervisor/supervisord.conf  
    • Close supervisor with Command
shutdown  

If the App.ini (control file) is built first, these configured programs will also start after using the start command

    • Startup program app.py
start program_name  

The program name here is [Program:name] in the config file ini, so the program_name here is Pmapp

    • Close the program app.py
stop program_name  
    • Refresh configuration file If you modify the INI file after startup, you can refresh the reload command by using the
supervisorctl reload  
    • To view the running status of a supervisor
ps -efH|grep supervisor  

Here is a reminder that if you do this, the following error occurs:

Error: .ini file does not include supervisorctl section  help, use /usr/local/bin/supervisorctl -h 

Or

error: <class ‘socket.error‘>, [Errno 101] Network is unreachable: file: /usr/lib/python2.7/socket.py line: 571 

Switch to the/etc/supervisor directory to execute the above command

Execution supervisorctl start APP_NAME or execution supervisorctl of related commands, if any

unix:///tmp/supervisor.sock no such file  

Description Supervisord Service has not started, check your supervisord.conf file final comment ; cancellation, files path no problem

[include]files = ./conf.d/*.ini  

Then rerun in the directory /etc/supervisor

supervisord -c /etc/supervisor/supervisord.conf  

Finally attach the supervisord service Run command

Reconfigure read files:supervisorctl reread

Restart Service:supervisorctl reload

To close the service:supervisorctl shutdown

Supervisor configuration Process

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.