#!/bin/sh export RAILS_ENV=production ACTION=$1 shift clear_cache() { rm -f ./public/javascripts/cache-*.js rm -f ./public/stylesheets/cache.css } do_start() { if ! rake db:abort_if_pending_migrations; then echo "========================================" echo "There are pending migrations, please upgrade the database before starting the production server" exit 1 fi clear_cache ./script/ferret_server -e $RAILS_ENV start ./script/feed-updater start mongrel_rails cluster::start } do_stop() { mongrel_rails cluster::stop ./script/feed-updater stop ./script/ferret_server -e $RAILS_ENV stop } case "$ACTION" in start|stop) do_$ACTION ;; restart) do_stop sleep 1 do_start ;; *) echo "usage: $0 start|stop|restart" exit 1 ;; esac