web2py.archlinux.sh 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/bash
  2. # the script should be run
  3. # from WEB2PY root directory
  4. prog="web2py.py"
  5. chmod +x $prog
  6. function web2py_start {
  7. nohup python2 ./$prog -a "<recycle>" >>/dev/null 2>/dev/null &
  8. pid=`pgrep -f $prog | tail -1`
  9. if [ "x$pid" != "x$$" ]
  10. then
  11. echo "WEB2PY has been started (pid $pid). Stop it with '$0 stop'"
  12. else
  13. echo "Failed to start WEB2PY."
  14. fi
  15. }
  16. function web2py_stop {
  17. pid="`pgrep -f $prog | grep -v $$`"
  18. if [ "x$pid" == "x" ]
  19. then
  20. echo "No WEB2PY processes to stop."
  21. else
  22. kill -15 $pid
  23. # Wait for web2py to shut down gracefully.
  24. sleep 2
  25. pid="`pgrep -f $prog | head -1`"
  26. if [ "x$pid" == "x" ]
  27. then
  28. echo "WEB2PY has been stopped."
  29. else
  30. echo "Failed to stop WEB2PY. (Possibly, only one of several web2py processes was killed.)"
  31. echo "Still running:"
  32. pgrep -af $prog
  33. fi
  34. fi
  35. }
  36. case "$1" in
  37. start)
  38. web2py_start
  39. ;;
  40. stop)
  41. web2py_stop
  42. ;;
  43. restart)
  44. web2py_stop
  45. web2py_start
  46. ;;
  47. *)
  48. echo "Usage: $0 [start|stop|restart]"
  49. ;;
  50. esac
  51. exit 0