What is the method for installing and configuring supervisor in Ubuntu?
Here is how you can install and configure Supervisor on Ubuntu:
- Install Supervisor using the following command:
sudo apt-get update
sudo apt-get install supervisor
- 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
- The directory where supervisor configuration files are stored is /etc/supervisor/conf.d/
- 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 ; (标准输出日志文件)
- After saving and closing the configuration file, reload the Supervisor configuration file.
sudo supervisorctl reread
sudo supervisorctl update
- 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.