Nandan Joshi
Nandan Joshi
1 min read

Categories

Tags

Introduction

Torquebox is a Ruby application platform incorporating supports for technologies such as Rails and Sinatra. It has built-in support for services and functionalities like messaging, scheduling, caching, daemons, clustering, load-balancing and high-availability. Basically the following diagramme describes it all.

Torquebox stack

Some Notes

This guide helps installing and setting up JRuby with Torquebox on Mac OS X Snow Leopard (OS X 10.6.8). This may vary on OS X Lion/Mountain Lion, but basically, it is similar. Creating an app and starting up the server is generally the same in all operating systems.

Installing and Setting Up

Get and install RVM

$ curl -L https://get.rvm.io | bash -s stable —ruby

Find the latest version of RVM

$ rvm get head
$ rvm requirements

Install Ruby

$ rvm install 1.9.3 —with-gcc=clang

Install JRuby

$ rvm get stable && rvm install jruby

Setting up Torquebox Gemset

$ rvm use jruby
$ rvm gemset create torquebox
$ rvm jeruby-1.7.0@torquebox

Install Torquebox Gem

Install Torquebox-Server via RVM and jruby gem install

jruby -S gem install torquebox-server

Install Rails3 for JRuby

jruby -S gem install rails —pre —no-doc —no-ri

Starting Up

Create Your Rails Project

Use the torquebox template for creating a new rails app, it puts it in a subfolder just like normal rails new myapp

$ torquebox rails myapp

Change to Rails App Directory

$ cd myapp

Do a Quick Test, this should load WEBrick

$ jruby script/rails server

Verify ENV vars

Run this and verify that your ENV vars are set properly, if not torquebox deploy/undeploy won’t work

$ torquebox env

Make sure your environment variables look something like this, your username instead of “username”

TORQUEBOX_HOME=/Users/nandan/.rvm/gems/jruby-1.7.0/gems/torquebox-server-2.1.2-java
JBOSS_HOME=/Users/nandan/.rvm/gems/jruby-1.7.0/gems/torquebox-server-2.1.2-java/jboss
JRUBY_HOME=/Users/nandan/.rvm/rubies/jruby-1.7.0

Set your JRUBY Options: run with 1.9.x, turn on jit logging (turn off to make quieter in term)

JRUBY_OPTS="--1.9 -Xjit.logging=true" 
JRUBY_OPTS="--1.9 -Xjit.logging=false"

Optional Stuff

If you added Gems Bundle Install to make sure we’re all set up, if not torquebox rails already handled this

$ jruby -S bundle install

Setup to Run on Torquebox

$ torquebox deploy .

Test Running on Torquebox

$ torquebox run

Browse localhost:8080 and voila! there it is!