#!/usr/bin/env bash GUNICORN_NAME="yfmonitor_gunicorn.py" function start_service() { echo "启动中请稍等" local DIR_NAME=$(cd `dirname "$0"`; pwd) local BASE_DIR="${DIR_NAME}/monitor" local start_file="${BASE_DIR}/${GUNICORN_NAME}" source activate yunfei_monitor >/dev/null 2>&1 python ${BASE_DIR}/supervisord/yf_supervisord.py gunicorn -c "${start_file}" monitor.wsgi:application sleep 1 local ret=$(ps axu | grep "${GUNICORN_NAME}" | grep -v grep | wc -l) if [[ ${ret} -gt 0 ]];then echo "服务启动成功" else echo -e "\033[31m 启动失败请检查 \033[0m" fi } function stop_service() { echo "停止服务中请稍等" ps axu | grep "${GUNICORN_NAME}" | grep -v grep | awk '{print $2}' | xargs kill -9 >/dev/null 2>&1 local ret=$(ps axu | grep "${GUNICORN_NAME}"| grep -v grep | wc -l) if [[ ${ret} -eq 0 ]];then echo "服务停止成功" start_service else echo -e "\033[31m 停止失败请检查 \033[0m" fi } #chown -R www:www /var/lib/nginx #chown -R www:www /data/szmg/www #chown -R www:www /data/szmg/img #chown -R www:www /data/szmg/app stop_service