Skip to content

Instantly share code, notes, and snippets.

@areichman
Created March 6, 2012 14:26
Show Gist options
  • Save areichman/1986553 to your computer and use it in GitHub Desktop.
Save areichman/1986553 to your computer and use it in GitHub Desktop.
Run the Rails console or rake tasks from a deployed JRuby war file
#!/bin/bash
# Print the usage statement and exit if no options are provided. Otherwise, set
# the required variables.
#
if [ $# -lt 1 ]
then
echo "Usage:"
echo "app console Start the console application"
echo "app test Run the test suite"
echo "app env Show details about the application environment"
exit
else
DIR="$( cd "$( dirname "$0" )" && pwd )"
cd $DIR/..
export GEM_HOME=vendor/bundler_gems
export GEM_PATH=$GEM_HOME
app_runner="java -cp lib/jruby-core-1.6.4.jar:lib/jruby-stdlib-1.6.4.jar org.jruby.Main -r ../META-INF/init" # relative to app.war/WEB-INF/lib
fi
# Run the specified utility
#
case "$1" in
console)
$app_runner script/rails console
;;
test)
$app_runner -S rake test
;;
env)
$app_runner -S rake about
echo ""
$app_runner -S gem env
$app_runner -S gem list
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment