我的环境是,CentOS Linux 7.7.1908 (Core) 网站是.netcore3.\
yum install supervisor
Total download size: 519 k
Installed size: 2.5 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): python-meld3-0.6.10-1.el7.x86_64.rpm | 73 kB 00:00:00
(2/2): supervisor-3.1.4-1.el7.noarch.rpm | 446 kB 00:00:00
-----------------------------------------------------------------------------------------------------------
Total 2.1 MB/s | 519 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : python-meld3-0.6.10-1.el7.x86_64 1/2
Installing : supervisor-3.1.4-1.el7.noarch 2/2
Verifying : python-meld3-0.6.10-1.el7.x86_64 1/2
Verifying : supervisor-3.1.4-1.el7.noarch 2/2
Installed:
supervisor.noarch 0:3.1.4-1.el7
Dependency Installed:
python-meld3.x86_64 0:0.6.10-1.el7
因为安装的版本supervisor.noarch 0:3.1.4-1.el7 很旧是2015年的, 所以我们要升级
on 6 Apr
3.4.0 …
1bd50f3 zip tar.gz
on 23 Dec 2018
3.3.5 …
4f356b7 zip tar.gz
on 16 Feb 2018
3.3.4 …
c773b73 zip tar.gz
on 25 Jul 2017
3.3.3 …
34b690a zip tar.gz
on 25 Jul 2017
3.2.4 …
6ddf270 zip tar.gz
on 25 Jul 2017
3.1.4 …
fbf9296 zip tar.gz
on 25 Jul 2017
3.0.1 …
00d6669 zip tar.gz
on 4 Jun 2017
3.3.2 …
42bfa55 zip tar.gz
on 3 Aug 2016
3.3.1 …
504e2fb zip tar.gz
on 15 May 2016
3.3.0 …
4142109 zip tar.gz
on 20 Mar 2016
3.2.3 …
8286f01 zip tar.gz
on 5 Mar 2016
3.2.2 …
26cc505 zip tar.gz
on 7 Feb 2016
3.2.1 …
b7e4ed8 zip tar.gz
on 1 Dec 2015
3.2.0 …
5fcab2c zip tar.gz
3.1.3 …
f067ed4 zip tar.gz
on 8 Sep 2014
3.1.2 …
7786119 zip tar.gz
on 12 Aug 2014
3.1.1 …
62dd947 zip tar.gz
on 30 Jul 2014
3.1.0 …
fa45f8f zip tar.gz
on 31 Jul 2013
3.0 …
b0cb098 zip tar.gz
on 29 May 2013
3.0b2 …
8a45b14 zip tar.gz
on 11 Sep 2012
3.0b1 …
34c43e9 zip tar.gz
on 7 Dec 2011
3.0a12 …
0e53f90 zip tar.gz
on 7 Dec 2011
3.0a11 …
fab3d25 zip tar.gz
on 31 Mar 2011
3.0a10 …
24ce360 zip tar.gz
https://github.com/Supervisor/supervisor/releases
我这里下载的是supervisor-3.4.0.tar.gz 因为系统的python是2.7.5 怕更高了需要3.0支持
https://github.com/Supervisor/supervisor/releases/tag/3.4.0
国内下载
https://download.csdn.net/download/liutietuo/12190996
cd /usr/local/src
tar -zxvf supervisor-3.4.0.tar.gz
cd supervisor-3.4.0
python setup.py install
Installed /usr/lib/python2.7/site-packages/supervisor-3.4.0-py2.7.egg
Traceback (most recent call last):
File "setup.py", line 86, in
'pidproxy = supervisor.pidproxy:main',
File "/usr/lib64/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/lib64/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/lib/python2.7/site-packages/setuptools/command/install.py", line 73, in run
self.do_egg_install()
File "/usr/lib/python2.7/site-packages/setuptools/command/install.py", line 101, in do_egg_install
cmd.run()
File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 380, in run
self.easy_install(spec, not self.no_deps)
File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 604, in easy_install
return self.install_item(None, spec, tmpdir, deps, True)
File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 655, in install_item
self.process_distribution(spec, dist, deps)
File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 701, in process_distribution
distreq.project_name, distreq.specs, requirement.extras
TypeError: __init__() takes exactly 2 arguments (4 given)
看到成功的安装提示 Installed /usr/lib/python2.7/site-packages/supervisor-3.4.0-py2.7.egg
但是有个报错, 怀疑是之前安装了版本的问题, 试试可用不
2.3 测试
supervisorctl status
提示没有配置文件,应该是正常的 我们先加配置文件
如果发现报错
error:
先yum安装一下老版本
之后就是
unix:///var/run/supervisor/supervisor.sock no such file
命令查看 /etc/supervisord.conf 这个文件
最结尾看到
[include]
files = supervisord.d/*.ini
所以只要是/etc/supervisord.d/下面的所有ini文件 都会被加载 .
有些作者会让新建/etc/supervisord目录,或者配置文件后缀是.conf 其实都要看软件版本,不能一概而论.
如果是dotnet网站先/etc/supervisord.d下建立一个dotnet.ini
[program:dotnet]
command=dotnet InterfaceWeb.dll
directory=/www/wwwroot/myweb/
environment=ASPNETCORE__ENVIRONMENT=Production
user=root
stopsignal=INT
autostart=true
autorestart=true
startsecs=1
stderr_logfile=/www/wwwroot/dotnet.err.log
stdout_logfile=/www/wwwroot/dotnet.out.log
注意这里的路径都要存在stderr_logfile 和 stdout_logfile .具体每个参数代表什么意思,应该也很容易理解, 我不用中文注释了,怕格式问题,导致加载失败.
如果是Redis等其他服务 配置基本类似.
[program:redis]
command=/usr/bin/redis-server /usr/local/redis/redis.conf
autorstart=true
autorestart=true
stdout_logfile=/tmp/supervisor.log
[program:usercenter]
directory = /home/leon/projects/usercenter ; 程序的启动目录
command = gunicorn -c gunicorn.py wsgi:app ; 启动命令,可以看出与手动在命令行启动的命令是一样的
autostart = true ; 在 supervisord 启动的时候也自动启动
startsecs = 5 ; 启动 5 秒后没有异常退出,就当作已经正常启动了
autorestart = true ; 程序异常退出后自动重启
startretries = 3 ; 启动失败自动重试次数,默认是 3
user = leon ; 用哪个用户启动
redirect_stderr = true ; 把 stderr 重定向到 stdout,默认 false
stdout_logfile_maxbytes = 20MB ; stdout 日志文件大小,默认 50MB
stdout_logfile_backups = 20 ; stdout 日志文件备份数
; stdout 日志文件,需要注意当指定目录不存在时无法正常启动,所以需要手动创建目录(supervisord 会自动创建日志文件)
stdout_logfile = /data/logs/usercenter_stdout.log
; 可以通过 environment 来添加需要的环境变量,一种常见的用法是修改 PYTHONPATH
; environment=PYTHONPATH=$PYTHONPATH:/path/to/somewhere
supervisord -c /etc/supervisord.conf #启动服务
systemctl enable supervisord #开机启动
systemctl is-enabled supervisord #验证是否开机启动
supervisord -c /etc/supervisord.conf #启动服务
supervisorctl shutdown #关闭
supervisorctl status:查看所有进程的状态
supervisorctl stop dotnet:停止dotnet
supervisorctl start dotnet:启动dotnet
supervisorctl restart dotnet: 重启dotnet
supervisorctl update :配置文件修改后可以使用该命令加载新的配置
supervisorctl reload: 重新启动配置中的所有程序
systemctl enable supervisord #开机启动
systemctl is-enabled supervisord #验证是否开机启动
查看状态supervisorctl status .看到如下 表示已经成功运行了
如果看到的是这样的错误
dotnet FATAL Exited too quickly (process log may have details)
检查 ini文件的路径 .
检查启动命令
检查完成后用下面的kill 干掉进程,重新执行supervisord -c /etc/supervisord.conf
这个是因为端口被占用 干掉进程 重新启动就行
查看 ps -aux|grep supervisord
kill *****
DeprecationWarning: Parameters to load are deprecated. Call .resolve and .require separately.
return pkg_resources.EntryPoint.parse("x="+spec).load(False)
这个是因为log文件问题, 大概率是因为版本过低,不支持stdout_logfile参数. 要保留这个就需要升级, 不需要就注释这个配置行就行
解开这个配置 /etc/supervisord.conf , 然后设置端口和账号密码
如果还不能访问, 检查一下端口是否被禁止了.
[inet_http_server] ; inet (TCP) server disabled by default
port=*:19901 ; (ip_address:port specifier, *:port for all iface)
username=do***et ; (default is no username (open server))
password=2hj******33 ; (default is no password (open server))
查看端口 netstat -nltp | grep 19901
看看宝塔面板是否没有放行你使用的端口
浏览器地址访问:
http://IP.IP.IP.IP:19901
输入配置的账号密码
username=do***et ; (default is no username (open server))
password=2hj******33 ; (default is no password (open server))
yum uninstall supervisor 等等