restart.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env bash
  2. GUNICORN_NAME="yfmonitor_gunicorn.py"
  3. function start_service() {
  4. echo "启动中请稍等"
  5. local DIR_NAME=$(cd `dirname "$0"`; pwd)
  6. local BASE_DIR="${DIR_NAME}/monitor"
  7. local start_file="${BASE_DIR}/${GUNICORN_NAME}"
  8. source activate yunfei_monitor >/dev/null 2>&1
  9. python ${BASE_DIR}/supervisord/yf_supervisord.py
  10. gunicorn -c "${start_file}" monitor.wsgi:application
  11. sleep 1
  12. local ret=$(ps axu | grep "${GUNICORN_NAME}" | grep -v grep | wc -l)
  13. if [[ ${ret} -gt 0 ]];then
  14. echo "服务启动成功"
  15. else
  16. echo -e "\033[31m 启动失败请检查 \033[0m"
  17. fi
  18. }
  19. function stop_service() {
  20. echo "停止服务中请稍等"
  21. ps axu | grep "${GUNICORN_NAME}" | grep -v grep | awk '{print $2}' | xargs kill -9 >/dev/null 2>&1
  22. local ret=$(ps axu | grep "${GUNICORN_NAME}"| grep -v grep | wc -l)
  23. if [[ ${ret} -eq 0 ]];then
  24. echo "服务停止成功"
  25. start_service
  26. else
  27. echo -e "\033[31m 停止失败请检查 \033[0m"
  28. fi
  29. }
  30. #chown -R www:www /var/lib/nginx
  31. #chown -R www:www /data/szmg/www
  32. #chown -R www:www /data/szmg/img
  33. #chown -R www:www /data/szmg/app
  34. stop_service