Running Padrino on JRuby

You can run Padrino on JRuby. Padrino 0.18.6 is tested on JRuby 10.1.


Install on JRuby

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

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

Create Padrino project just as you do when using MRI:

$ padrino g project jrack-test -e erb

cd ./jrack-test and now you can go:

$ bundle install && bundle binstubs --all

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

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


Deploying on JRuby

Warbler packages an app as a WAR file with JRuby-Rack, which doesn't support Rack 3. Padrino 0.18 needs Rack 3, so a WAR built from a Padrino 0.18 project fails to start (cannot load such file -- rack/chunked). Serve the project with a Rack server that runs on JRuby instead, such as Puma. Add it to your Gemfile:

gem 'puma'

Then run:

$ bundle install
$ padrino start -e production -a puma -h 0.0.0.0 -p 3000

Type to search the guides.