Supervisor使用手册

285 阅读1分钟

supervisor:安装的软件的名称。
supervisord:装好supervisor后,supervisord用于启动supervisor服务。
supervisorctl:用于管理supervisor配置文件中program和supervisor服务本身。

安装

pip install supervisor 或者

yum install epel-release
yum install supervisor  

生成配置文件

  • 创建文件夹 mkdir -p /etc/supervisor
  • 生成配置文件 echo_supervisord_conf > /etc/supervisor/supervisord.conf
  • 指定配置文件 supervisord -c /etc/supervisor/supervisord.conf

配置外网访问

[inet_http_server]         ; inet (TCP) server disabled by default
port=0.0.0.0:9001        ; ip_address:port specifier, *:port for all iface
username=user              ; default is no username (open server)
password=123               ; default is no password (open server)

run Python程序

[program:myProgram]
command=/root/miniconda3/envs/spider/bin/python /home/project/pythonProject/fastapi-beanie/app/main.py
autostart=true
autorestart=true
stdout_logfile=/home/project/pythonProject/fastapi-beanie/my_log.log

开机启动

systemctl enable supervisord

重载配置文件

image.png

访问ip:9001

image.png