在AWS AMI Linux服务器上设置Supervisord [英] Setting up Supervisord on a AWS AMI Linux Server
问题描述
我正在尝试使主管工作,以确保我的队列系统始终运行。
以下是我采取的步骤,我从各种渠道整理了这些步骤:
(以root用户或超级用户身份运行)
1)
$ easy_install主管
2)
$ echo_supervisord_conf> /etc/supervisord.conf
3)
$ sudo visupervisord.conf
4)
将以下内容粘贴到文件末尾:
command = / usr / bin / php / path / to / AppName / artisan --env = production --timeout = 240 queue:listen
5)
$ supervised -c /etc/supervisord.conf
6)
$主管
7)主管>状态
主管>
它不显示任何内容。
这是我的解决方案。 AWS AMI包含用于安装Python应用程序的pip。以下是设置命令:
$ sudo pip安装主管
$ echo_supervisord_conf
$ sudo su-
$ echo_supervisord_conf> /etc/supervisord.conf
安装超级用户后,您将需要手动构建启动脚本打开和关闭服务。
这将随您的Linux发行版而有所不同,Ubuntu将在您安装时为您创建一个初始化脚本,而其他发行版(如AMI)则不会。这是各种Linux发行版初始化脚本的绝佳资源:
https://github.com/Supervisor/initscripts
然后您可以将超级用户添加到chkconfig中,以在系统重启时自动启动。
以下是对我有用的一个>>
路径
/etc/init.d/supervisord
示例初始化脚本适用于AWS-AMI或RedHat Linux
#!/ bin / bash
#
#有监督的启动脚本主管过程控制系统
#
#作者:Mike McGrath< mmcgrath@redhat.com> (基于yumupdatesd)
#Jason Koppe< jkoppe@indeed.com>调整为读取sysconfig,
#使用受监管的工具启动/停止,有条件地等待
#子进程关闭,然后再启动
#Erwan Queffelec< erwan.queffelec@gmail.com> ;
#使脚本符合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 supervisor
2) $ echo_supervisord_conf > /etc/supervisord.conf
3) $ sudo vi supervisord.conf
4) Pasted the following to end of file:
command=/usr/bin/php /path/to/AppName/artisan --env=production --timeout=240 queue:listen
5) $ supervisord -c /etc/supervisord.conf
6) $ supervisorctl
7) supervisor> status
supervisor>
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.conf
After 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/initscripts
You can then add supervisor to chkconfig to get started automatically on system reboot.
Here is one that works for me:
Path
/etc/init.d/supervisord
Example Init Script for AWS-AMI or RedHat Linux
#!/bin/bash # # supervisord Startup script for the Supervisor process control system # # Author: Mike McGrath <mmcgrath@redhat.com> (based off yumupdatesd) # Jason Koppe <jkoppe@indeed.com> adjusted to read sysconfig, # use supervisord tools to start/stop, conditionally wait # for child processes to shutdown, and startup later # Erwan Queffelec <erwan.queffelec@gmail.com> # 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 settings if [ -f /etc/sysconfig/supervisord ]; then . /etc/sysconfig/supervisord fi # Path to the supervisorctl script, server binary, # and short-form for messages. 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 $"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 $RETVAL
After you close and save, make it executable by all users:
chmod a+x /etc/init.d/supervisord
You would next want to confirm that the supervisord process is in fact running by running the following command:
ps -fe | grep supervisor
If you don't see /usr/bin/supervisord as a running process then you need to start it up manually:
sudo service supervisord start
Supervisord 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 list
sudo chkconfig --add supervisord
Then tell chkconfig to turn it on after boot
sudo chkconfig supervisord on
这篇关于在AWS AMI Linux服务器上设置Supervisord的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!