Guest User

Untitled

a guest
Apr 23rd, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. #
  4. PATH="/bin:/usr/bin:/usr/local/bin"
  5.  
  6. APP_BASE_DIR="/path/to/u/apps"
  7. APPS="`ls ${APP_BASE_DIR}/*/Rakefile`"
  8. USER="mongrel"
  9.  
  10. export RAILS_ENV="production"
  11.  
  12. ##
  13. # Subroutines.
  14. run_all_mongrels() {
  15. type="${1}"
  16. errors="${2}"
  17. silent="${3}"
  18. echo "INFO: action - ${type} all RoR applications."
  19. for i in ${APPS} ; do
  20. dir="`echo $i |sed 's/Rakefile$//'`"
  21. cd "${dir}"; su "${USER}" -c "rake ${silent} util:mongrel_init:${type} 2> ${errors}"
  22. done
  23. }
  24.  
  25. run_one_mongrel() {
  26. type="${1}"
  27. app="${2}"
  28. echo "INFO: action - ${type} ${2}."
  29. cd "${APP_BASE_DIR}/${app}"
  30. cd "${dir}"; su "${USER}" -c "rake -s util:mongrel_init:${type}"
  31. }
  32.  
  33. ##
  34. # Main.
  35. case "${1}" in
  36. start)
  37. if [ -z "${2}" ]; then
  38. run_all_mongrels "start" "/var/tmp/`basename $0`.errors"
  39. else
  40. run_one_mongrel "start" "${2}"
  41. fi
  42. ;;
  43.  
  44. stop)
  45. if [ -z "${2}" ]; then
  46. run_all_mongrels "stop" "/var/tmp/`basename $0`.errors"
  47. else
  48. run_one_mongrel "stop" "${2}"
  49. fi
  50. ;;
  51.  
  52. list)
  53. run_all_mongrels "name" "/dev/null" "-s"
  54. ;;
  55.  
  56. *)
  57. echo "Usage: mongrel_cluster { start { APPLICATION } | stop { APPLICATION } | list }"
  58. exit 0
  59. ;;
  60.  
  61. esac
  62.  
  63.  
  64. exit 0
Add Comment
Please, Sign In to add comment