What is the method for installing and configuring supervisor in Ubuntu?

Here is how you can install and configure Supervisor on Ubuntu:

  1. Install Supervisor using the following command:
sudo apt-get update
sudo apt-get install supervisor
  1. The configuration file for Supervisor is located at /etc/supervisor/supervisord.conf.
[unix_http_server]
file=/var/run/supervisor.sock ; (the path to the socket file)

[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (log level;default info; others: debug,warn,trace)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024)
minprocs=200 ; (min. avail process descriptors;default 200)
user=root ; (default is current user, required if root)

[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL  for a unix socket

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///var/run/supervisor.sock
  1. The directory where supervisor configuration files are stored is /etc/supervisor/conf.d/
  2. I just need one option – .conf
[program:program_name]
command=/path/to/program ; (启动命令)
autostart=true ; (是否开机自动启动)
autorestart=true ; (进程意外退出是否自动重启)
stderr_logfile=/var/log/program.err.log ; (错误日志文件)
stdout_logfile=/var/log/program.out.log ; (标准输出日志文件)
  1. After saving and closing the configuration file, reload the Supervisor configuration file.
sudo supervisorctl reread
sudo supervisorctl update
  1. Start the Supervisor service:
sudo service supervisor start

At this point, Supervisor has been successfully installed and configured. You can utilize Supervisor to manage various processes, monitor their running status, and perform management tasks.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds