jetty-rackup

本文介绍如何使用Jetty部署基于Ruby和Sinatra的Web应用程序。通过Jetty-rackup项目,可以将Sinatra应用作为Rack应用运行在Jetty Servlet容器中,避免了warbler打包的复杂性。

geekq/jetty-rackup

jetty-rackup

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:

  • write your Rack based application as usual
  • create a rackup script config.ru as usual; there is more information in
    the official tutorial
    http://wiki.github.com/rack/rack/tutorial-rackup-howto
  • install jetty-rackup (this project), e.g.
    git clone git://github.com/geekq/jetty-rackup.git
  • from your application folder run jetty-rackup. You can also provide
    a path to non-standard rackup-script and the desired port
    number for the server to run.

Now your application runs inside jetty servlet container. Enjoy!

Example

$cat config.ru

#\ -p 8765
require 'rubygems'
gem 'sinatra', '~> 0.9.4'
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

Binaries

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值