||
supervisor
安装
python -m pip install supervisor
在/etc目录下生成配置文件,可能需要root用户
echo_supervisord_conf > supervisord.conf
添加读取目录,使得会自动读取/etc/supervisor目录下的所有conf文件的配置
[include]
files = /etc/supervisor/*.conf ; relative/directory/*.ini
启动supervisord服务
sudo supervisord
Error: Cannot open an HTTP server: socket.error reported errno.EACCES (13)
配置文件中 /var/run 文件夹,没有授予启动 supervisord 的相应用户的写权限。/var/run 文件夹实际上是链接到 /run,因此我们修改 /run 的权限。
sudo chmod 777 /run
http://blog.51cto.com/8838848/1736058
------------------------------
修改配置添加网络管理界面
出于安全考虑,默认配置是没有开启web管理界面,需要修改supervisord.conf配置文件打开http访权限,将下面的配置: 把前面的注释;去掉就可以了。配合nginx 实现外网访问。
[inet_http_server]
port=0.0.0.0:9001
username=user
password=123
参考: https://blog.csdn.net/LHWorldBlog/article/details/78518696
-----------------------------------------------
Supervisor服务管理shadowsocks进程
前段时间为公司搭建了一台shadowsocks服务器,然后用一段时间,shadowsocks的进程老是莫名其妙的挂掉,所以我就准备用supervisor来管理这个进程,实现自动重启。supervisor搭建的过程我就不再赘述,网上有很多文档。下面是我在supervisor中写的主要配置:
[program:ssserver]
command =/usr/bin/ssserver -c /etc/shadowsocks.json -d start
autostart=true
autorestart=true
startsecs=3
如上配置以后,发现supervisor并没有实现对shadowsocks的自动重启,然后我在命令行下执行了command发现是正常的,而且shadowsocks的进程也是启动的,但是在supervisorctl命令行中看到如下一条记录:
ssserver FATAL Exited too quickly (process log may have details)
很奇怪,为什么我的进程是正常运行的,但是在supervisor中却显示FATAL。后来通过查资料发现,supervisor无法管理后台运行的程序,需要程序为前台运行方式,然后我将配置改为如下:
[program:ssserver]
command =/usr/bin/ssserver -c /etc/shadowsocks.json
autostart=true
autorestart=true
startsecs=3 重新启动等待的时间,单位是s.
将shadowsocks的启动命令由后台demon模式变成前台模式,问题就的到了解决。
报错,产看log文件。
shadowsocks FATAL Exited too quickly (process log may have details)
supervisor> status
shadowsocks BACKOFF Exited too quickly (process log may have details)
supervisor> status
shadowsocks FATAL Exited too quickly (process log may have details)
supervisor> start shadowsocks
shadowsocks: started
supervisor> status
shadowsocks RUNNING pid 24091, uptime 0:00:06
---------------
hexo必须在对应的目录下才能启动服务,
在supervisor配置文中指定相应的工作目录接可以了
[program:hexoczq]
directory = /home/czq/hexoczq
command = hexo s --config _config.yml
user = czq
autostart = true
autoresart = true
stderr_logfile = /var/log/hexo/hexoczq.stderr.log
stdout_logfile = /var/log/hexo/hexoczq.stdout.log
https://blog.csdn.net/xia7139/article/details/9033483
------------------------------------------
-------------
http://www.cashqian.net/blog/001472975510127673ea63db9234c4e8293cf43cefcafde000
unix:///tmp/supervisor.sock no such file
cd进/tmp/
目录看了下,果然没有supervisor.sock
文件。前一阵子用的时候还没有问题的。上网查了下,原来supervisor默认配置会把socket文件和pid守护进程生成在/tmp/
目录下,/tmp/
目录是缓存目录,Linux会根据不同情况自动删除其下面的文件。原因找到了,就好办了,将supervisor配置文件里的相应地方改掉就好了。
打开配置文件
https://www.restran.net/2015/10/04/supervisord-tutorial/
vi /etc/supervisord.conf
修改如下标示的几行即可
[unix_http_server];file=/tmp/supervisor.sock ; (the path to the socket file) ; 修改为 /var/run 目录,避免被系统删除; chmod=0700 ; socket file mode (default 0700); chown=nobody:nogroup ; socket file uid:gid owner;username=user ; (default is no username (open server));password=123 ; (default is no password (open server))...[supervisord];logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)logfile=/var/log/supervisor/supervisord.log ; 修改为 /var/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=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)pidfile=/var/run/supervisord.pid ; 修改为 /var/run 目录,避免被系统删除...[supervisorctl]; 必须和'unix_http_server'里面的设定匹配;serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socketserverurl=unix:///var/run/supervisor.sock ; 修改为 /var/run 目录,避免被系统删除;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket;username=chris ; should be same as http_username if set;password=123 ; should be same as http_password if set...
serverurl=unix:///var/run/supervisor.sock ;
这里把所有的/tmp路径改掉,/tmp/supervisor.sock 改成 /var/run/supervisor.sock,/tmp/supervisord.log 改成 /var/log/supervisor.log,/tmp/supervisord.pid 改成 /var/run/supervisor.pid 要不容易被linux自动清掉
---------------------
作者:Horizon_LGMH
来源:CSDN
原文:https://blog.csdn.net/qq_28885149/article/details/79364685
版权声明:本文为博主原创文章,转载请附上博文链接!
保存退出后再执行如下语句,加载更新过的配置文件
supervisorctl update
至此就可以了,socket文件supervisor.sock
和守护进程supervisord.pid
两个文件放在/var/run/
下面,log文件supervisord.log
放在/var/log/
下面。
--------------
supervisor手动关闭:
/usr/bin/supervisorctl stop all 先关闭supervisor启动脚本,之后再关闭supervisord服务
kill pid
ps -aux|grep supervisord -m1|awk '{print $2}'|xargs -I @ sudo kill -9 @
注意一定要先关闭里面启动的脚本;这样才能方便下次管理。
否则需要先手动关闭supervisor管理的服务;
手动关闭ssserver;
ps -aux|grep ssser
kill -9 pid
手动关闭hexo;
ps -aux|grep hexo
kill -9 pid
----------------------------------------------------------------------------------------------------------------
unix:///var/run/supervisor.sock no such file
sudo touch /var/run/supervisor.sock
sudo chmod 777 /var/run/supervisor.sock
sudo service supervisor restart
-----------------------------------------------------------------------------------------------------------
unix:///var/run/supervisor.sock refused connection
sudo supervisord
----------------------------------------------------------------------------------------------------------
感觉配置没有问题,依然启动不了,可尝试下面命令
sudo supervisorctl update
sudo supervisorctl reload
sudo supervisorctl status
-------------------------------------------------------------------------------------------------------------
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-4-19 20:31
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社