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)
以下是我采取的步骤,我从各种来源拼凑起来:(以root身份或超级用户身份)
1) $ easy_install supervisor
1)$ easy_install主管
2) $ echo_supervisord_conf > /etc/supervisord.conf
2)$ echo_supervisord_conf> /etc/supervisord.conf
3) $ sudo vi supervisord.conf
3)$ sudo vi supervisord.conf
4) Pasted the following to end of file:
4)将以下内容粘贴到文件末尾:
command=/usr/bin/php /path/to/AppName/artisan --env=production --timeout=240 queue:listen
command = / usr / bin / php / path / to / AppName / artisan --env = production --timeout = 240 queue:listen
5) $ supervisord -c /etc/supervisord.conf
5)$ supervisord -c /etc/supervisord.conf
6) $ supervisorctl
6)$ supervisorctl
7) supervisor> status
7)主管>地位
supervisor>
主管>
It does not display anything.
它不显示任何内容。
2 个解决方案
#1
29
Here is the solution I went with. AWS AMI includes pip for installing Python applications. Here are the setup commands:
这是我选择的解决方案。 AWS AMI包括用于安装Python应用程序的pip。以下是设置命令:
$ 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.
安装Supervisor后,您需要手动构建启动脚本以打开和关闭服务。
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:
这将因您的Linux发行版而异,Ubuntu会在您安装时为您创建一个init脚本,而AMI等其他发行版则不会。这是各种Linux发行版初始化脚本的绝佳资源:
https://github.com/Supervisor/initscripts
https://github.com/Supervisor/initscripts
You can then add supervisor to chkconfig to get started automatically on system reboot.
然后,您可以将管理程序添加到chkconfig以在系统重新引导时自动启动。
Here is one that works for me:
这是一个适合我的方法:
Path
路径
/etc/init.d/supervisord
Example Init Script for AWS-AMI or RedHat Linux
AWS-AMI或RedHat Linux的示例Init脚本
#!/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:
接下来,您需要通过运行以下命令来确认supervisord进程实际上正在运行:
ps -fe | grep supervisor
If you don't see /usr/bin/supervisord as a running process then you need to start it up manually:
如果您没有将/ usr / bin / supervisord视为正在运行的进程,则需要手动启动它:
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.
需要在重新启动服务器的任何时候启动Supervisord。这可以类似于使用chkconfig重启后如何打开apache。
First add it to chkconfig, your start up process list
首先将它添加到chkconfig,即启动进程列表
sudo chkconfig --add supervisord
Then tell chkconfig to turn it on after boot
然后告诉chkconfig在启动后将其打开
sudo chkconfig supervisord on
#2
4
supervisor doesn't know that you have added a program. This is answered on serverfault, do the following:
主管不知道你已经添加了一个程序。这在serverfault上得到解答,请执行以下操作:
supervisorctl reread
supervisorctl update
By the way, it's easier to maintain configuration files using the conf.d
syntax. In other words, create a file called /etc/supervisor/conf.d/artisan.conf
. Everything else is the same, but it's easier to version control your configuration files and sync them to machines on setup.
顺便说一句,使用conf.d语法维护配置文件更容易。换句话说,创建一个名为/etc/supervisor/conf.d/artisan.conf的文件。其他所有内容都是相同的,但是更容易对配置文件进行版本控制并在设置时将它们同步到计算机上。
#1
29
Here is the solution I went with. AWS AMI includes pip for installing Python applications. Here are the setup commands:
这是我选择的解决方案。 AWS AMI包括用于安装Python应用程序的pip。以下是设置命令:
$ 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.
安装Supervisor后,您需要手动构建启动脚本以打开和关闭服务。
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:
这将因您的Linux发行版而异,Ubuntu会在您安装时为您创建一个init脚本,而AMI等其他发行版则不会。这是各种Linux发行版初始化脚本的绝佳资源:
https://github.com/Supervisor/initscripts
https://github.com/Supervisor/initscripts
You can then add supervisor to chkconfig to get started automatically on system reboot.
然后,您可以将管理程序添加到chkconfig以在系统重新引导时自动启动。
Here is one that works for me:
这是一个适合我的方法:
Path
路径
/etc/init.d/supervisord
Example Init Script for AWS-AMI or RedHat Linux
AWS-AMI或RedHat Linux的示例Init脚本
#!/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:
接下来,您需要通过运行以下命令来确认supervisord进程实际上正在运行:
ps -fe | grep supervisor
If you don't see /usr/bin/supervisord as a running process then you need to start it up manually:
如果您没有将/ usr / bin / supervisord视为正在运行的进程,则需要手动启动它:
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.
需要在重新启动服务器的任何时候启动Supervisord。这可以类似于使用chkconfig重启后如何打开apache。
First add it to chkconfig, your start up process list
首先将它添加到chkconfig,即启动进程列表
sudo chkconfig --add supervisord
Then tell chkconfig to turn it on after boot
然后告诉chkconfig在启动后将其打开
sudo chkconfig supervisord on
#2
4
supervisor doesn't know that you have added a program. This is answered on serverfault, do the following:
主管不知道你已经添加了一个程序。这在serverfault上得到解答,请执行以下操作:
supervisorctl reread
supervisorctl update
By the way, it's easier to maintain configuration files using the conf.d
syntax. In other words, create a file called /etc/supervisor/conf.d/artisan.conf
. Everything else is the same, but it's easier to version control your configuration files and sync them to machines on setup.
顺便说一句,使用conf.d语法维护配置文件更容易。换句话说,创建一个名为/etc/supervisor/conf.d/artisan.conf的文件。其他所有内容都是相同的,但是更容易对配置文件进行版本控制并在设置时将它们同步到计算机上。