JBoss.orgCommunity Documentation

Chapter 2. TorqueBox Installation

2.1. Installation using RubyGems
2.2. Installation using Complete Binary Distribution
2.2.1. Ensure you have Java 6
2.2.2. Get the latest version of TorqueBox binary package
2.2.3. Unzip it somewhere handy
2.2.4. Configuring Your Database
2.2.5. How to run TorqueBox
2.3. Setting JVM Properties
2.4. Setting JRuby Properties

TorqueBox 2 can be installed entirely as a RubyGem. For details, please see Chapter 20, torquebox-server Gem. TorqueBox can also be installed from a binary distribution as described below.

The latest Complete Binary Distribution contains:

Note: these instructions assume you are running on a unix-like system. If you are using Windows, you will need to adjust the file-system paths and environment variables accordingly.

We'll install TorqueBox under your user's $HOME directory.

$ unzip -q torquebox-dist-2.3.1-bin.zip
      

Before using the TorqueBox server, you must set up your environment. To make it easier to upgrade without having to reconfigure your environment, it is useful to create a symlink to the versioned directory produced when you unpackaged the distribution.

$ ln -s torquebox-2.3.1 torquebox-current

Next, $TORQUEBOX_HOME, $JBOSS_HOME and $JRUBY_HOME need to be set, and adjusting your $PATH will make working with the package easier. You can either run the following commands each time on the command-line, or add them to your .bash_profile.

First, the various $X_HOME variables are set so that each subsystem can find its supporting files.

export TORQUEBOX_HOME=$HOME/torquebox-current
export JBOSS_HOME=$TORQUEBOX_HOME/jboss
export JRUBY_HOME=$TORQUEBOX_HOME/jruby

Next, we make sure that JRuby's binaries are first in our executable $PATH, before any previously-installed Ruby packages.

export PATH=$JRUBY_HOME/bin:$PATH

By doing this, commands such as rake, gem, and rails will load from the TorqueBox-provided JRuby installation.

You can also run TorqueBox using your own install of JRuby by installing the TorqueBox gems.

$ jruby -S gem install torquebox

You will also need to set $JRUBY_HOME to point to your JRuby installation.

Note: if you are going to run a non-bundled JRuby with a prerelease build of TorqueBox, it is recommended that you either use a separate rvm gemset for each prerelease build, or be sure to reinstall the TorqueBox gems for the latest prerelease. There is a blog post on torquebox.org describing how to set up your torquebox environment with RVM.

For prerelease builds, you will also need to ensure that your gem command can find the prerelease TorqueBox gems by adding http://torquebox.org/2x/builds/LATEST/gem-repo/ to your ~/.gemrc file and including the --pre flag to gem install.

$ cat ~/.gemrc
--- 
:sources: 
- http://rubygems.org
- http://torquebox.org/2x/builds/LATEST/gem-repo/

If using the torquebox command (Chapter 17, The torquebox Command), JVM properties can be set with the -J flag. The only caveat is hypens must be escaped with a "\".

For example:

$ torquebox run -J "\-Xmx2048m \-Djruby.jit.logging=true"

If using standalone.sh, just append the JVM properties to the end of the command.

For example:

$ $JBOSS_HOME/bin/standalone.sh -Djruby.jit.logging=true

If you'd prefer not to pass the JVM properties on the commandline, they can also be set in $JBOSS_HOME/bin/standalone.conf by appending to the JAVA_OPTS variable.

For example:

...
if [ "x$JAVA_OPTS" = "x" ]; then
   JAVA_OPTS="-Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"
   JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS -Djava.awt.headless=true"
   JAVA_OPTS="$JAVA_OPTS -Djboss.server.default.config=standalone.xml"
else
   echo "JAVA_OPTS already set in environment; overriding default settings with values: $JAVA_OPTS"
fi

JAVA_OPTS="$JAVA_OPTS -Djruby.jit.logging=true"

You can also set the JAVA_OPTS environment variable directly in the shell, but if you do this make sure you copy the increased MaxPermSize from $JBOSS_HOME/bin/standalone.conf since if JAVA_OPTS is set in the shell the defaults in this file won't be applied.

For example:

$ export JAVA_OPTS="-Xmx1024m -XX:MaxPermSize=256m -Djruby.jit.logging=true"

While some JRuby properties can be set via torquebox.yml or torquebox.rb as shown in Section 5.2.4, “Ruby runtime configuration”, JRuby supports many more options than the ones TorqueBox exposes directly. As long as you are using the torquebox command (Chapter 17, The torquebox Command), you can set these other properties with the JRUBY_OPTS environment variable.

For example:

$ export JRUBY_OPTS="-X+C --1.9 -Xjit.logging=true"
$ torquebox run

If you are not using the torquebox command, JRUBY_OPTS can still be used for options like "--1.9", "--1.8", "-X+C", "+X-O", but not for options of the style "-Xa.b" like "-Xjit.logging=true". The latter options will need to be set as JVM properties (Section 2.3, “Setting JVM Properties”) by prefixing them with "jruby." like "-Djruby.jit.logging=true".

For example:

$ export JRUBY_OPTS="-X+C --1.9"
$ $JBOSS_HOME/bin/standalone.sh -Djruby.jit.logging=true