
系统和软件环境 CentOS 7 monit(yum 安装,版本 5.14)
手动运行 /bin/bash /data/wwwroot/xxx.com/xxx/xxx.sh start 总能成功
用 monit 运行总是显示执行失败
配置文件
check process xxx with pidfile /var/run/xxx.pid start program = "/bin/bash /data/wwwroot/xxx.com/xxx/xxx.sh start" stop program = "/bin/bash /data/wwwroot/xxx.com/xxx/xxx.sh stop" xxx.sh 脚本
#!/bin/bash NAME="xxx" # Name of the application DJANGODIR=/data/wwwroot/xxx.com/xxx # Django project directory SOCKFILE=/tmp/${NAME}.sock # we will communicte using this unix socket PIDFILE=/var/run/${NAME}.pid USER=www # the user to run as GROUP=www # the group to run as NUM_WORKERS=3 # how many worker processes should Gunicorn spawn DJANGO_SETTINGS_MODULE=xxx.settings # which settings file should Django use DJANGO_WSGI_MODULE=xxx.wsgi # WSGI module name start() { echo "Starting $NAME as `whoami`" # Activate the virtual environment cd $DJANGODIR source .venv/bin/activate export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE export PYTHOnPATH=$DJANGODIR:$PYTHONPATH # Create the run directory if it doesn't exist RUNDIR=$(dirname $SOCKFILE) test -d $RUNDIR || mkdir -p $RUNDIR # Start your Django Unicorn # Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon) exec gunicorn ${DJANGO_WSGI_MODULE}:application \ --name $NAME \ --workers $NUM_WORKERS\ --user=$USER --group=$GROUP \ --bind=unix:$SOCKFILE \ --pid=$PIDFILE \ --worker-class=meinheld.gmeinheld.MeinheldWorker --daemon } stop() { kill `cat $PIDFILE` } case $1 in start) start ;; stop) stop ;; *) echo "usage: ${NAME} {start|stop}" ;; esac exit 0 1 fcicq 2016-08-23 21:41:43 +08:00 想用这些 supervisor 就要去掉 daemon |
3 mephisto 2016-08-24 10:45:29 +08:00 |