supervisor的使用

(1)安装和配置

  • Linux直接安装
yum install supervisor
  • 使用Python安装(更新到最新的pip)
pip3 install supervisor
  • 启动服务
supervisord -c /etc/supervisord.conf

(2)基础命令

  • 重新启动配置中的所有程序
    supervisorctl reload

  • 查看进程运行状态
    supervisorctl status

  • 启动进程
    supervisorctl start 进程名

  • 关闭进程
    supervisorctl stop 进程名

  • 重启进程
    supervisorctl restart 进程名

  • 有新配就要更新supervisor
    supervisorctl update

  • 关闭supervisord
    supervisorctl shutdown

  • 进程名 清空进程日志
    supervisorctl clear

(3)配置

/etc/supervisor.d/xxx.conf

部署Flask应用程序

[program:gunicorn]
directory=/home/flaskapp
command=gunicorn -w 4 -b :5000 --log-level=warning flaskweb:app
user=root
autostart=true
autorestart=true
loglevel=info
stdout_logfile=/var/log/gunicorn-stdout.log
stderr_logfile=/var/log/gunicorn-stderr.log

部署Go-Gin应用程序

编译打包:go build -o ginweb main.go

[program:ginweb]
directory=/home/ginweb
command=ginweb
user=root
autostart=true
autorestart=true
loglevel=info
stdout_logfile=/var/log/ginweb-stdout.log
stderr_logfile=/var/log/ginweb-stderr.log
posted @ 2022-10-26 10:27  你的代码写得很烂  阅读(20)  评论(0编辑  收藏  举报