Get the App
SLTechnology News&Howtos  ›  Servers  › 

Detailed tutorials on using supervisor for centos7

Shulou Source: shulou.com Published: 2022-06-02 04:07:04 10月04日 Update

supervisor is a general process management program developed in Python, which can turn an ordinary command-line process into a background daemon and monitor the process status. It can automatically restart when exiting abnormally.

Install supervisor

# yum search setuptools.... python-setuptools.noarch : Easily build and distribute Python packages #yum install -y python-setuptools.noarch #easy_install supervisor

Creating a Master Profile

# mkdir -m 755 -p /etc/supervisor \\Create supervisor configuration file directory # echo_supervisor_conf >/etc/supervisor/supervisor.conf \\Create main configuration file # cd /etc/supervisor/# mkdir -m 755 conf.d \\Create project profile directory

Create project profile (run 3 scripts)

# vim conf.d/test.ini[program:tjapp_sendmessage]command=/bin/bash /data/shell/sendmessage.shnumprocs=1autostart=trueautorestart=true [program:bbscollection]command=/bin/bash /data/shell/bbscollection.shnumprocs=1autostart=trueautorestart=true [program:test_sbbscollection]command=/bin/bash /data/shell/test_sbbscollection.shnumprocs=1autostart=trueautorestart=true

Introduce test.ini in the main configuration file

#cat supervisord.conf... [include]files = ./ conf.d/*.ini

Start supervisor

# supervisord -c /etc/supervisord.conf

View scripts run by supervisor

# supervisorctlbbscollection RUNNING pid 10090, uptime 4 days, 17:20:10test_sbbscollection RUNNING pid 10088, uptime 4 days, 17:20:10tjapp_sendmessage RUNNING pid 10089, uptime 4 days, 17:20:10

Stop the bbcollection script

# supervisorctl stop bbscollectionbbscollection: stopped[root@om-web_test supervisord.d]# supervisorctlbbscollection STOPPED Apr 06 10:23 AMtest_sbbscollection RUNNING pid 10088, uptime 4 days, 17:23:13tjapp_sendmessage RUNNING pid 10089, uptime 4 days, 17:23:13 supervisor> start bbcollection\\Start supervisor> statusbbcollection RUNNING pid 7310, uptime 0:00:24test_sbbscollection RUNNING pid 10088, uptime 4 days, 17:23:54tjapp_sendmessage RUNNING pid 10089, uptime 4 days, 17:23:54

The above is all the content of this article, I hope to help everyone's study, but also hope that everyone a lot of support.

Tags: Files configurations scripts directories processes projects runs normal content background commands that is status programs learning help development support monitoring management Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux OPPO Reno Shulou Tech Info MariaDB Xiaomi