Runs a rack conform application inside jetty web server
MIT License
For the newer projects we decided to switch from MRI to JRuby. One of the bigger questions is certainly the deployment.
Reading and trying all the warbler stuff, we had enough of packaging and
wanted to do it the Ruby/Sinatra way (with a standalone script, where
one can consciously start things like run Sinatra::Application
from a
rackup script).
Embedding jetty is also mentioned in the jetty documentation "For many applications, HTTP is just another interface protocol. Jetty can easily be embedded in such applications and products without adopting a WWW centric application architecture."
So here is the solution:
config.ru
as usual; there is more information ingem install jetty-rackup
orgit clone git://github.com/geekq/jetty-rackup.git
jetty-rackup
. You can also provideNow your application runs inside jetty servlet container. Enjoy!
$cat config.ru
#\ -p 8765
require 'rubygems'
gem 'sinatra', '>= 1.0.0'
require './my_app.rb'
set :run, false # disable built-in sinatra web server
set :environment, :development
set :base_url, 'http://xxtrial' # custom application option
run Sinatra::Application
The jetty and jruby-rack binaries are now provided for your convinience. But you can also download a different version of them, if you wish, from the official web sites of the respective projects:
The major gem version (7) now matches the used jetty version.
What's the best way to set max memory?
jruby -J-Xmx2048m /usr/local/lib/jetty-rackup/jetty-rackup config.ru
There are no automated tests for jetty-rackup. But there are some example applications with rackup configuration. Just cd to the particular example directory and run. E.g.
cd examples/just_ruby/
jetty-rackup
firefox http://localhost:9292/stranger
jetty-rackup uses config.ru
file from the current directory by
default.
Host
option. In addition to specifying portpid
option - create pid fileFor Rails deployment you may prefer jetty-rails http://jetty-rails.rubyforge.org/
(c) 2009 Vodafone Group Services GmbH
(c) 2013 Vladimir Dobriakov
Vladimir Dobriakov http://blog.geekq.net, http://www.mobile-web-consulting.de
With contributions by Leandro Silva, Jason Rogers and erdeszt.