2015-07-01 22 views
8

Arka planda bir süreç olarak bir deamon çalıştırmaya çalışıyorum ancak kullanıcı olarak root kullandığımda çalışıyorum.Linux CentOS 7 süpervizörü yalnızca root ile çalıştırıldığında çalışır

Bu benim yaptığım budur.

$ yum -y install python-setuptools 

$ easy_install supervisor 

$ echo_supervisord_conf > /etc/supervisor/supervisord.conf 

yeni bir kullanıcı eklemek varsayılan ayarlarla doldurmak yapılandırma klasörler

$ mkdir -p /etc/supervisor/conf.d 

oluşturulan kendi web sitesinde söyledi gibi yüklü amiri

otomatik başlamasını sağlamak için CentOS

Bu

$ vim /usr/lib/systemd/system/supervisord.service 

yeniden başlatma başlayacak biçimde şimdi onu etkinleştirebilirsiniz

[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             

aşağıdaki kodu eklendi yapmak zorunda. Her şey yolunda.

$ systemctl enable supervisord 

$ systemctl start supervisord 

$ systemctl status supervisord 

Tamam

basit bir program

ekleyerek dosyanın

[include] 
files = /etc/supervisor/conf.d/*.conf 

sonunda ekleyerek conf.d klasörüne

$ vim /etc/supervisor/supervisord.conf 

dosyaları dahil etmek yapılandırma dosyasını düzenleme

$ 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 yeniden başlatma

hiçbir hata

supervisord ama hiçbir şey

$ systemctl status supervisord 

o supervisord ancak cin programı çalışmakta olduğunu gösterir olur yeniden halinde sürecin

çalışmaz.

ben

$ supervisorctl status main 

çalıştırırsanız

$ supervisorctl reload 

ben hata alıyorum hata

error: <class 'socket.error'>, [Errno 111] Connection refused: file: /usr/lib64/python2.7/socket.py line: 571 

olsun çalıştırırsanız

http://localhost:9001 refused connection 

Zaten selinux'u devre dışı bıraktım.

Ancak garip kısım, her ikisini de root olarak değiştirirsem çalışır.

Yürütücü, kullanıcı grubu ve diğerleri tarafından yürütülebilir.

Neler olup bittiği hakkında hiçbir fikrim yok. Güvenlik nedenleriyle bir web sunucusu çalıştıran kullanıcı olarak kökü kullanmam gerektiğini duydum.

+2

bunu çözdük mü bir hizmet olarak kaydetmek? Evet ise nasıl? –

+7

https://imgs.xkcd.com/comics/wisdom_of_the_ancients.png – Basil

cevap

4

Orada aynı sorun yaşayan tüm insanlar için, bu benim için çalışır. (I nereden bulduğunu unutmayın, bu senaryonun Özür değil sahibini artık i düğünle)

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 bu içerikleri yapıştırın
#!/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 

dosyasına çalıştırma ve

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 
+1

/etc/rc.d/init.d artık mevcut değil. Komut dosyanızı /etc/init.d dizininde oluşturmanız gerekir, bu yüzden yola dikkat edin. –

İlgili konular