Closed. This question does not meet Stack Overflow guidelines。它当前不接受答案。












想改善这个问题吗?更新问题,以便将其作为on-topic用于堆栈溢出。

1年前关闭。



Improve this question




我试图让主管工作以确保我的队列系统始终在运行。

以下是我采取的步骤,这些步骤是我从各种来源整理而来的:
(以 super 用户或 super 用户身份运行)

1)
$ easy_install主管

2)
$ echo_supervisord_conf> /etc/supervisord.conf

3)
$ sudo vi administratord.conf

4)
将以下内容粘贴到文件末尾:

命令= / usr / bin / php / path / to / AppName / artisan --env = production --timeout = 240队列:听

5)
$ super 用户-c /etc/supervisord.conf

6)
$ supervisorctl

7)主管>状态

主管>

它不显示任何内容。

最佳答案

这是我的解决方案。 AWS AMI包含用于安装Python应用程序的pip。这是设置命令:

$ sudo pip install supervisor
$ echo_supervisord_conf
$ sudo su -
$ echo_supervisord_conf > /etc/supervisord.conf

安装主管后,您将需要手动构建启动脚本以打开和关闭服务。

这将随您的Linux发行版而有所不同,Ubuntu将在您安装时为您创建一个初始化脚本,而其他发行版(如AMI)则不会。这是各种Linux发行版初始化脚本的重要资源:

https://github.com/Supervisor/initscripts

然后,您可以将 super 用户添加到chkconfig中,以在系统重新引导时自动开始。

这是一个对我有用的东西:

路径
/etc/init.d/supervisord

适用于AWS-AMI或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 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

关闭并保存后,使其可被所有用户执行:
chmod a+x /etc/init.d/supervisord

接下来,您需要通过运行以下命令来确认受监控进程是否正在运行:
 ps -fe | grep supervisor

如果您没有将/ usr / bin / supervisord视为正在运行的进程,则需要手动启动它:
sudo service supervisord start

每次重新引导服务器时,都需要启动Supervisord。可以类似于使用chkconfig在重新启动后打开apache的方式进行此操作。

首先将其添加到chkconfig中,这是您的启动过程列表
sudo chkconfig --add supervisord

然后告诉chkconfig在启动后将其打开
sudo chkconfig supervisord on

关于amazon-web-services - 在AWS AMI Linux服务器上设置Supervisord ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28702780/

10-11 09:00