Padrino

Advanced Usage

Running Padrino on JRuby

You can run Padrino (0.9.29 ... 0.10.5 is tested) on JRuby 1.7.27


Install on JRuby

You can easily install Padrino on jruby when you use RVM:

$ rvm install jruby-1.7.27
$ rvm use --create jruby-1.7.27@padrino
$ gem install bundler
$ gem install padrino -v=0.10.5

Create Padrino project just as you do when using MRI or REE:

$ padrino g project jrack-test -e erb

cd ./jrack-test and you should edit Gemfile:

# JRuby deployment requirements
# please add these lines...
gem 'jruby-openssl'
gem 'jruby-rack'
gem 'warbler'

Now you can go:

$ bundle

Then, create the test controller:

$ padrino gen controller index get:index get:hello get:show_path

A controller sample is here:

# app/controllers/index.rb

JrackTest::App.controllers :index do
  get :index do
    "Hello, JPadrino!"
  end

  get :hello, :map => '/:id' do
    "Hello, #{params[:id]}!"
  end

  get :show_path, :map => '/show-path/*urls' do
    "You accessed: #{params[:urls].inspect}"
  end
end

Then run:

$ padrino s

To run JRuby on 1.9 compat mode:

alias padrino='jruby --1.9 -S padrino'
padrino start

You can access http://localhost:3000 as you run padrino on MRI...


How to create WAR

Now you should install the warbler gem with $ gem install warbler, so you can:

$ warble config

Edit config/warble.rb if you want to apply some customizations. You can access JRuby-Rack official README and Warbler rdoc.

For example, if you want to deploy the app to server root directory, just add to config/warble.rb:

config.jar_name = "jrack-test"

Deploying with JRuby on 1.9 compat mode:

config.webxml.jruby.compat.version = "1.9"

If you are ready, run:

$ warble war

You would get jrack-test.war (the same name as your project directory name), and you can deploy this war file to tomcat! I tested on tomcat 6.0.20, and it works well with quick response.

last updated: 2022-02-22

comments powered by Disqus