shutdown.sh 725 B

123456789101112131415161718192021222324252627282930
  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. systemctl stop jimvc.service
  11. systemctl status jimvc.service -l
  12. # 服务结束后,/run/jimv/jimvc.pid 文件会被 gunicorn 自动清除。如果该文件还存在,则表示服务依然活着。
  13. # 在执行 systemctl stop 后,若服务任然活着,则强制结束。
  14. if [ -f '/run/jimv/jimvc.pid' ]; then
  15. if [ -f '/run/jimv/jimvc.pid' ]; then
  16. killall -9 gunicorn
  17. rm -f /run/jimv/jimvc.pid
  18. echo 'JimV-C is forced to terminate.';
  19. exit 1
  20. fi
  21. fi
  22. if [ ! -e '/run/jimv/jimvc.pid' ]; then
  23. echo 'JimV-C stopped.';
  24. fi