centos7 supervisord

安装

yum install supervisor -y

用户配置文件

cd  /etc/supervisor/conf.d/ 
cat testsssping.ini 
[program:testsssping]
#command=sh /data/test.sh
stderr_logfile=/tmp/supervisor.err.log
stdout_logfile=/tmp/supervisor.out.log
command=ping www.baidu.com
autostart=true
autorestart=true
user=otoyix
startsecs=5

启动

systemctl start supervisord.service
supervisorctl restart/stop/restart/start testsssping
testsssping: stopped
testsssping: started
[root@VM-16-15-centos supervisord.d]# supervisorctl status
testsssping                      RUNNING   pid 27746, uptime 0:00:32
[root@VM-16-15-centos supervisord.d]# ps -ef|grep ping
otoyix   27746 27745  0 11:54 ?        00:00:00 ping www.baidu.com

普通用户使用 supervisorctl

正常情况下普通用户没有权限使用supervisorctl,会报以下错误

[root@VM-16-15-centos supervisord.d]# su otoyix
[otoyix@VM-16-15-centos supervisord.d]$ supervisorctl status
error: <class 'socket.error'>, [Errno 13] Permission denied: file: /usr/lib64/python2.7/socket.py line: 224

解决方法

chown -R otoyix:otoyix /var/log/supervisor/
chmod -R 777 /var/run/supervisor
vim /etc/supervisord.conf
user=otoyix                 ; (default is current user, required if root)

有权限了
[otoyix@VM-16-15-centos supervisord.d]$ supervisorctl status
testsssping                      RUNNING   pid 28334, uptime 0:07:21

普通用户使用systemctl

正常情况下普通用户使用systemctl时会提示root密码

[otoyix@VM-16-15-centos supervisord.d]$ systemctl restart supervisord.service      
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: root
Password: Failed to restart supervisord.service: Connection timed out
See system logs and 'systemctl status supervisord.service' for details.
[otoyix@VM-16-15-centos supervisord.d]$ polkit-agent-helper-1: pam_authenticate failed: Authentication failure

解决方法

cp -r /usr/share/polkit-1/actions/org.freedesktop.systemd1.policy{,.bak}
cat /usr/share/polkit-1/actions/org.freedesktop.systemd1.policy|grep -Ei 'defaults|allow'
                <defaults>
                        <allow_any>no</allow_any>
                        <allow_inactive>no</allow_inactive>
                        <allow_active>auth_admin_keep</allow_active>
                </defaults>
                <defaults>
                        <allow_any>yes</allow_any>
                        <allow_inactive>yes</allow_inactive>
                        <allow_active>yes</allow_active>
                </defaults>
                <defaults>
                        <allow_any>yes</allow_any>
                        <allow_inactive>yes</allow_inactive>
                        <allow_active>yes</allow_active>
                </defaults>
                <defaults>
                        <allow_any>yes</allow_any>
                        <allow_inactive>yes</allow_inactive>
                        <allow_active>yes</allow_active>
                </defaults>
                
systemctl restart supervisord.service

-------------------end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值