> 路径 /etc/init.d/supervisord 示例初始化脚本适用于AWS-AMI或RedHat Linux #!/ bin / bash ##有监督的启动脚本主管过程控制系统##作者:Mike McGrath< [email protected]> (基于yumupdatesd)#Jason Koppe< [email protected]>调整为读取sysconfig,#使用受监管的工具启动/停止,有条件地等待#子进程关闭,然后再启动#Erwan Queffelec< [email protected]> ; #使脚本符合LSB要求##chkconfig:345 83 04 #说明:Supervisor是一个允许\ #用户的客户端/服务器系统在\ #类似UNIX的操作系统上监视和控制许多进程。 #进程名:主管#配置:/etc/supervisord.conf #配置:/ etc / sysconfig / supervisord #pidfile:/var/run/supervisord.pid # ###开始信息#提供:有监督的#必需开始:$ all #必需停止:$ all #短-描述:启动和停止Supervisor过程控制系统#描述:Supervisor是一个允许的客户端/服务器系统#它的用户可以监视和控制上的多个进程#类似于UNIX操作系统。 ###结束初始化信息 #源函数库。 /etc/rc.d/init.d/functions #源系统设置如果[-f / etc / sysconfig / supervisord];然后。 / etc / sysconfig / supervisord fi #supervisorctl脚本,服务器二进制文件,#和消息格式的路径。 supervisorctl = / usr / local / bin / supervisorctl supervisord = $ {SUPERVISORD- / usr / local / bin / supervisord} prog = supervisord pidfile = $ {PIDFILE- /tmp/supervisord.pid} lockfile = $ {LOCKFILE- / var / lock / subsys / supervisord} STOP_TIMEOUT = $ {STOP_TIMEOUT-60} OPTIONS = $ {OPTIONS-- c /etc/supervisord.conf} RETVAL = 0 start(){ echo -n $启动$ prog: 守护程序--pidfile = $ {pidfile} $ supervisord $ OPTIONS RETVAL = $? echo [b $ bbb if [$ RETVAL -eq 0];然后 touch $ {lockfile} $ supervisorctl $ OPTIONS状态 fi return $ RETVAL } stop(){ echo -n $停止$ prog: killproc -p $ {pidfile} -d $ {STOP_TIMEOUT} $ supervisord RETVAL = $? echo [$ RETVAL -eq 0]&& rm -rf $ {lockfile} $ {pidfile} } reload(){ echo -n $ Reloading $ prog: LSB = 1 killproc -p $ pidfile $ supervisord -HUP RETVAL = $? echo if [$ RETVAL -eq 7];然后失败$ $ prog reload 其他 $ supervisorctl $ OPTIONS状态 fi } restart(){ stop start } 情况 $ 1在 start中) start ;; 止损)止损 ;; 状态)状态-p $ {pidfile} $ supervisord RETVAL = $? [$ RETVAL -eq 0]&& $ supervisorctl $ OPTIONS状态 ;; restart)重新启动 ;; condrestart | try-restart)如果状态为-p $ {pidfile} $ supervisord>& / dev / null;然后停止开始 fi ;; force-reload | reload) reload ;; *) echo $用法:$ prog {开始|停止|重新启动| condrestart |尝试重新启动|强制重新加载|重新加载} RETVAL = 2 esac 退出$ RETVAL 关闭并保存后,使其所有人可执行用户: chmod a + x /etc/init.d/supervisord 接下来,您需要通过运行以下命令来确认受监控进程是否正在运行: ps -fe | grep主管 如果您没有将/ usr / bin / supervisord视为正在运行的进程,则需要手动启动它: sudo服务监督启动 每次重新引导服务器时,都需要启动Supervisord。 首先将其添加到chkconfig中,这是您的启动过程列表。 sudo chkconfig-添加主管 然后告诉chkconfig在启动后将其打开 sudo chkconfig受 监督/ pre> I'm trying to get supervisor working to make sure my queue system is always running.Here are the steps I took, which I pieced together from various sources:(Ran as root or super user)1)$ easy_install supervisor2)$ echo_supervisord_conf > /etc/supervisord.conf3)$ sudo vi supervisord.conf4)Pasted the following to end of file:command=/usr/bin/php /path/to/AppName/artisan --env=production --timeout=240 queue:listen5)$ supervisord -c /etc/supervisord.conf6)$ supervisorctl7) supervisor> statussupervisor>It does not display anything. 解决方案 Here is the solution I went with. AWS AMI includes pip for installing Python applications. Here are the setup commands:$ sudo pip install supervisor$ echo_supervisord_conf$ sudo su -$ echo_supervisord_conf > /etc/supervisord.confAfter you install supervisor you will need to manually build your start-up script to turn the service on and off.This will vary with your Linux distro, Ubuntu will create an init script for you when you install, other distros like AMI will not. Here is a great resource for various Linux distro init-up scripts:https://github.com/Supervisor/initscriptsYou can then add supervisor to chkconfig to get started automatically on system reboot.Here is one that works for me:Path/etc/init.d/supervisordExample Init Script for AWS-AMI or RedHat Linux#!/bin/bash## supervisord Startup script for the Supervisor process control system## Author: Mike McGrath <[email protected]> (based off yumupdatesd)# Jason Koppe <[email protected]> adjusted to read sysconfig,# use supervisord tools to start/stop, conditionally wait# for child processes to shutdown, and startup later# Erwan Queffelec <[email protected]># make script LSB-compliant## chkconfig: 345 83 04# description: Supervisor is a client/server system that allows \# its users to monitor and control a number of processes on \# UNIX-like operating systems.# processname: supervisord# config: /etc/supervisord.conf# config: /etc/sysconfig/supervisord# pidfile: /var/run/supervisord.pid#### BEGIN INIT INFO# Provides: supervisord# Required-Start: $all# Required-Stop: $all# Short-Description: start and stop Supervisor process control system# Description: Supervisor is a client/server system that allows# its users to monitor and control a number of processes on# UNIX-like operating systems.### END INIT INFO# Source function library. /etc/rc.d/init.d/functions# Source system settingsif [ -f /etc/sysconfig/supervisord ]; then . /etc/sysconfig/supervisordfi# Path to the supervisorctl script, server binary,# and short-form for messages.supervisorctl=/usr/local/bin/supervisorctlsupervisord=${SUPERVISORD-/usr/local/bin/supervisord}prog=supervisordpidfile=${PIDFILE-/tmp/supervisord.pid}lockfile=${LOCKFILE-/var/lock/subsys/supervisord}STOP_TIMEOUT=${STOP_TIMEOUT-60}OPTIONS="${OPTIONS--c /etc/supervisord.conf}"RETVAL=0start() { echo -n $"Starting $prog: " daemon --pidfile=${pidfile} $supervisord $OPTIONS RETVAL=$? echo if [ $RETVAL -eq 0 ]; then touch ${lockfile} $supervisorctl $OPTIONS status fi return $RETVAL}stop() { echo -n $"Stopping $prog: " killproc -p ${pidfile} -d ${STOP_TIMEOUT} $supervisord RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -rf ${lockfile} ${pidfile}}reload() { echo -n $"Reloading $prog: " LSB=1 killproc -p $pidfile $supervisord -HUP RETVAL=$? echo if [ $RETVAL -eq 7 ]; then failure $"$prog reload" else $supervisorctl $OPTIONS status fi}restart() { stop start}case "$1" in start) start ;; stop) stop ;; status) status -p ${pidfile} $supervisord RETVAL=$? [ $RETVAL -eq 0 ] && $supervisorctl $OPTIONS status ;; restart) restart ;; condrestart|try-restart) if status -p ${pidfile} $supervisord >&/dev/null; then stop start fi ;; force-reload|reload) reload ;; *) echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload}" RETVAL=2 esac exit $RETVALAfter you close and save, make it executable by all users:chmod a+x /etc/init.d/supervisordYou would next want to confirm that the supervisord process is in fact running by running the following command: ps -fe | grep supervisorIf you don't see /usr/bin/supervisord as a running process then you need to start it up manually:sudo service supervisord startSupervisord needs to be started up anytime that the server is rebooted. This can be done similar to how apache is turned on after reboot using chkconfig.First add it to chkconfig, your start up process listsudo chkconfig --add supervisordThen tell chkconfig to turn it on after bootsudo chkconfig supervisord on 这篇关于在AWS AMI Linux服务器上设置Supervisord的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
06-29 05:25