大佬教程收集整理的这篇文章主要介绍了Linux CentOS 7上的Supervisord仅在使用root运行时才有效,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这就是我所做的.
在他们的网站上告知已安装的主管
$yum -y install python-setuptools $easy_install supervisor
创建了配置文件夹
$mkdir -p /etc/supervisor/conf.d
使用默认设置填充
$echo_supervisord_conf > /etc/supervisor/supervisord.conf
$useradd gogopher
在CentOS 7上让它自动启动我必须这样做
$vim /usr/lib/systemd/system/supervisord.service
[Unit] Description=supervisord - Supervisor process control system for UNIX Documentation=http://supervisord.org After=network.target [service] Type=forking ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf ExecReload=/usr/bin/supervisorctl reload ExecStop=/usr/bin/supervisorctl shutdown User=gogopher [Install] WantedBy=multi-user.target
$systemctl enable supervisord $systemctl start supervisord $systemctl status supervisord
好
$vim /etc/supervisor/supervisord.conf
[include] files = /etc/supervisor/conf.d/*.conf
$vim /etc/supervisor/conf.d/goapp.conf [program:main] command=/srv/www/websiteurl.com/bin/main autostart=true autorestart=true startretries=10 user=gogopher
$systemctl重启supervisord
没有错误,但过程不起作用
如果我重启没有任何反应
$systemctl status supervisord
表明它是supervisord正在运行但不是守护程序.
如果我跑
$supervisorctl reload
我收到了错误
error: <class 'socket.error'>,[Errno 111] Connection refused: file: /usr/lib64/python2.7/socket.py line: 571
如果我跑
$supervisorctl status main
我收到了错误
http://localhost:9001 refused connection
我已经禁用了selinux.
但奇怪的是,如果我将它们都改为root,它就可以了.
所以我不知道发生了什么.我听说我不应该使用
root作为出于安全原因运行Web服务器的用户.
cd echo_supervisord_conf > /etc/supervisord.conf # content of /etc/supervisord.conf ... [supervisorctl] serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket [inet_http_server] ; inet (TCp) server disabled by default port=*:9001 ; (ip_address:port specifier,*:port for all ifacE) - I had all this wrong from my original config. username=user password=passwd
将此内容粘贴到/etc/rc.d/init.d/supervisord(我不是这个脚本的所有者,现在我不记得我从哪里得到它)
#!/bin/sh # # /etc/rc.d/init.d/supervisord # # Supervisor is a client/server system that # allows its users to monitor and control a # number of processes on UNIX-like operating # systems. # # chkconfig: - 64 36 # description: Supervisor Server # processname: supervisord # source init functions . /etc/rc.d/init.d/functions prog="supervisord" prefix="/usr/local/" exec_prefix="${prefix}" prog_bin="${exec_prefix}/bin/supervisord -c /etc/supervisord.conf" PIDFILE="/var/run/$prog.pid" start() { echo -n $"StarTing $prog: " daemon $prog_bin --pidfile $PIDFILE sleep 1 [ -f $PIDFILE ] && success $"$prog startup" || failure $"$prog startup" echo } stop() { echo -n $"ShutTing down $prog: " [ -f $PIDFILE ] && sleep 1 && killproc $prog || success $"$prog shutdown" echo } case "$1" in start) start ;; stop) stop ;; status) status $prog ;; restart) stop start ;; *) echo "Usage: $0 {start|stop|restart|status}" ;; esac
使脚本可执行并将其注册为服务
sudo chmod +x /etc/rc.d/init.d/supervisord sudo chkconfig --add supervisord sudo chkconfig supervisord on # Start the service sudo service supervisord start # Stop the service sudo service supervisord stop # Restart the service sudo service supervisord restart
以上是大佬教程为你收集整理的Linux CentOS 7上的Supervisord仅在使用root运行时才有效全部内容,希望文章能够帮你解决Linux CentOS 7上的Supervisord仅在使用root运行时才有效所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。