supervisor 安装和基本使用

安装

yum install supervisor
touch  /var/run/supervisor/supervisor.sock
chmod 777  /var/run/supervisor/supervisor.sock
supervisord
supervisorctl start all
supervisorctl status

配置目录:/etc/supervisor.d

基于swoft的配置

[program:user-center-gift]
process_name=%(program_name)s_%(process_num)02d
command=/usr/local/php/bin/php /home/www/userCenter/bin/swoft gift:write
autostart=true
autorestart=true
user=root
numprocs=1
redirect_stderr=true
stdout_logfile=/home/www/supervisor_user-center-gift.log

[program:test]
# 设置命令在指定的目录内执行
directory=/www/go/src/gin-api
# 这里为您要管理的项目的启动命令
command=/www/go/src/gin-api/test
# 以哪个用户来运行该进程
user=root
# supervisor 启动时自动该应用
autostart=true
# 进程退出后自动重启进程
autorestart=true
# 进程持续运行多久才认为是启动成功
startsecs=1
# 重试次数
startretries=3
# stderr 日志输出位置
stderr_logfile=/www/go/src/gin-api/runtime/stderr.log
# stdout 日志输出位置
stdout_logfile=/www/go/src/gin-api/runtime/stdout.log

命令

#查看所有服务的状态
supervisorctl status
服务名 = user-center-gift:user-center-gift_00
#启动服务
supervisorctl start 服务名
#停止服务
supervisorctl stop 服务名
#重启服务
supervisorctl restart 服务名

常见报错

端口占用

Starting supervisor: Error: Another program is already listening on a port that one of our HTTP servers is configured to use.  Shut this program down first before starting supervisord.
For help, use /usr/bin/supervisord -h

显示的是有另一个进程占用了监听端口

查出来 kill掉
ps -ef | grep supervisord

提示setuptools版本问题

/usr/local/lib/python2.7/dist-packages/pkg_resources/py2_warn.py:21: UserWarning: Setuptools will stop working on Python 2
************************************************************
You are running Setuptools on Python 2, which is no longer
supported and
>>> SETUPTOOLS WILL STOP WORKING <<<
in a subsequent release (no sooner than 2020-04-20).
Please ensure you are installing
Setuptools using pip 9.x or later or pin to `setuptools<45`
in your environment.
If you have done those things and are still encountering
this message, please follow up at
https://bit.ly/setuptools-py2-warning.
************************************************************
  sys.version_info < (3,) and warnings.warn(pre + "*" * 60 + msg + "*" * 60)
supervisor>

先看下版本

root@xxxxxx:~# which python
/usr/bin/python
root@xxxxxx:~# /usr/bin/python -V
Python 2.7.12

root@xxxxxx:~# which pip
/usr/bin/pip
root@xxxxxx:~# pip -V
pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)

升级

pip2 install --upgrade --user pip

#使用pip 9.x或更高版本的Setuptools或固定setuptools<45在您的环境中
pip2 install --user "setuptools<45"
posted @ 2023-02-12 17:03  快乐的提千万  阅读(86)  评论(0编辑  收藏  举报