JBoss.orgCommunity Documentation
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:
The TorqueBox server, ready-to-run
A complete JRuby installation
Additional RubyGems for use in other contexts
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.
TorqueBox requires Java JDK 6.
To determine which version, if any, is installed on your system, at
a command-line, attempt to run the java command with
the -version argument.
$java -versionjava version "1.6.0_07" Java(TM) SE Runtime Environment (build 1.6.0_07-b06-153) Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_07-b06-57, mixed mode)
If the version is at least 1.6, your version of Java is sufficient.
If you have no Java installed, or a version less than 1.6, you'll need to install a Java Development Kit. For many systems, it is easy to install the open-source OpenJDK.
For installation on Ubuntu, Fedora, OpenSuse, or Debian, please
refer to the installation
instructions provided by the OpenJDK project. If you find a
java on your system, ensure that it is not actually
gcj, as it is insufficient for
running the TorqueBox server.
For Apple OSX systems, Apple provides a JDK version 6.
You can obtain the latest version of TorqueBox from the TorqueBox repository. As of this writing, the latest version is 2.3.1.
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 $
variables are set so that each subsystem can find its supporting
files.X_HOME
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/
TorqueBox includes distributed (XA) transaction support by default. In order to take advantage of XA, you may need to alter your database configuration. See Section 15.4, “Database Configuration” for details.
Running TorqueBox essentially amounts to running JBoss:
$$JBOSS_HOME/bin/standalone.sh
TorqueBox also ships rake tasks and the torquebox binary, both of which can be used to start the server. See Section 18.4, “Server control” and Section 17.3, “torquebox run” for more details.
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