shutdown.sh 714 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env bash
  2. #
  3. # JimV-C
  4. #
  5. # Copyright (C) 2017 JimV <james.iter.cn@gmail.com>
  6. #
  7. # Author: James Iter <james.iter.cn@gmail.com>
  8. #
  9. # Shutdown the JimV-C.
  10. kill `cat /run/jimv/jimvc.pid`
  11. sleep 1
  12. # 服务结束后,/run/jimv/jimvc.pid 文件会被 gunicorn 自动清除。如果该文件还存在,则表示服务依然活着。
  13. # 在执行本脚本 2 秒后,若服务任然活着,则强制结束。
  14. if [ -f '/run/jimv/jimvc.pid' ]; then
  15. sleep 1
  16. if [ -f '/run/jimv/jimvc.pid' ]; then
  17. killall -9 gunicorn
  18. rm -f /run/jimv/jimvc.pid
  19. echo 'JimV-C is forced to terminate.';
  20. exit 1
  21. fi
  22. fi
  23. if [ ! -e '/run/jimv/jimvc.pid' ]; then
  24. echo 'JimV-C stopped.';
  25. fi