Skip to content

Instantly share code, notes, and snippets.

@wayneeseguin
Forked from flippyhead/gist:612337
Created October 6, 2010 00:58
Show Gist options
  • Select an option

  • Save wayneeseguin/612627 to your computer and use it in GitHub Desktop.

Select an option

Save wayneeseguin/612627 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Copyright (c) 2007 Bradley Taylor, [email protected]
#
# Modifications by Wayne E. Seguin
#
# mongrel_cluster Startup script for Mongrel clusters.
#
# chkconfig: - 85 15
# description: mongrel_cluster manages multiple Mongrel processes for use \
# behind a load balancer.
# Ensure RVM environment gets loaded.
environment_file=${environment_file:-/usr/local/rvm/environments/ruby-1.8.7-p302}
if [[ -s "$environment_file" ]] ; then
source "$environment_file"
else
echo "ERROR: RVM Environment file $environment_file missing."
fi
cluster_ctl=$(command -v mongrel_cluster_ctl)
if [[ $? -gt 0 ]] ; then
echo "ERROR: 'mongrel_cluster_ctl' command not found."
exit 1
fi
config_path=${config_path:-/etc/mongrel_cluster}
if [[ ! -d "$config_path" ]] ; then
echo "ERROR: configuration directory '$config_path' does not exist."
fi
pid_path=${pid_path:-/var/run/mongrel_cluster}
user=${user:-mongrel}
case "$1" in
start)
mkdir -p "$pid_path" # Ensure pid path exists.
chown $user:$user "$pid_path"
ruby "$cluster_ctl" start -c "$config_path"
;;
stop)
ruby "$cluster_ctl" stop -c "$config_path"
;;
restart)
ruby "$cluster_ctl" restart -c "$config_path"
;;
status)
ruby "$cluster_ctl" status -c "$config_path"
;;
*)
echo "Usage: mongrel_cluster {start|stop|restart|status}"
false
;;
esac
exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment