jetty-rackup 7.1.0 → 7.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -76,6 +76,14 @@ particular example directory and run. E.g.
76
76
  jetty-rackup uses `config.ru` file from the current directory by
77
77
  default.
78
78
 
79
+ What's new
80
+ ----------
81
+ * 7.2.0
82
+ + Add support for `Host` option. In addition to specifying port
83
+ now a host ip can also be specified if e.g. you only wish to bind the
84
+ server only to the loopback interface 127.0.0.1 and not to all IPs.
85
+ + Add support for `pid` option - create pid file
86
+
79
87
  See also
80
88
  --------
81
89
  For Rails deployment you may prefer jetty-rails
@@ -0,0 +1,9 @@
1
+ require 'sinatra'
2
+
3
+ get '/?' do
4
+ "hello from root url"
5
+ end
6
+
7
+ get '/:message/?' do |message|
8
+ "Hello #{message}"
9
+ end
@@ -0,0 +1,8 @@
1
+ #\ -p 8765 -o 127.0.0.1 --pid /tmp/jetty-example.pid
2
+ require 'rubygems'
3
+ require 'app'
4
+
5
+ set :run, false # disable built-in sinatra web server
6
+ set :environment, :development
7
+
8
+ run Sinatra::Application
@@ -5,7 +5,6 @@
5
5
  automatic = false
6
6
  server_type = nil
7
7
  env = "development"
8
- pid = nil
9
8
  options = {:Port => 9292, :Host => "0.0.0.0", :AccessLog => []}
10
9
 
11
10
  opts = OptionParser.new("", 24, ' ') { |opts|
@@ -59,8 +58,10 @@ opts = OptionParser.new("", 24, ' ') { |opts|
59
58
  daemonize = d ? true : false
60
59
  }
61
60
 
62
- opts.on("-P", "--pid FILE", "file to store PID (default: rack.pid)") { |f|
63
- pid = File.expand_path(f)
61
+ opts.on("-P", "--pid FILE", "file to store PID") { |file|
62
+ file = File.expand_path(file)
63
+ puts "Creating PID file '#{file}'"
64
+ File.write(file, java.io.File.new('/proc/self').canonical_file.name)
64
65
  }
65
66
 
66
67
  opts.separator ""
@@ -2,6 +2,8 @@ class Rack::Handler::Jetty
2
2
  def self.run(rackup_content, options={})
3
3
  Dir["#{File.dirname(__FILE__)}/../../jars/*.jar"].each { |jar| require jar }
4
4
 
5
+ java_import 'java.net.InetAddress'
6
+ java_import 'java.net.InetSocketAddress'
5
7
  java_import 'javax.servlet.http.HttpServlet'
6
8
  java_import 'org.eclipse.jetty.server.Server'
7
9
  java_import 'org.eclipse.jetty.servlet.ServletContextHandler'
@@ -13,7 +15,9 @@ class Rack::Handler::Jetty
13
15
  java_import 'org.eclipse.jetty.server.handler.ContextHandlerCollection'
14
16
  java_import 'org.eclipse.jetty.servlet.DefaultServlet'
15
17
 
16
- jetty = org.eclipse.jetty.server.Server.new options[:Port]
18
+ bind_to_address = java.net.InetAddress.getByName(options[:Host])
19
+ socket_address = java.net.InetSocketAddress.new(bind_to_address, options[:Port])
20
+ jetty = org.eclipse.jetty.server.Server.new(socket_address)
17
21
 
18
22
  context = org.eclipse.jetty.servlet.ServletContextHandler.new(nil, "/", org.eclipse.jetty.servlet.ServletContextHandler::NO_SESSIONS)
19
23
  context.add_filter("org.jruby.rack.RackFilter", "/*", 0)
@@ -1,5 +1,5 @@
1
1
  module Jetty
2
2
  module Rackup
3
- VERSION = "7.1.0"
3
+ VERSION = "7.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: jetty-rackup
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 7.1.0
5
+ version: 7.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Vladimir Dobriakov
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-12-30 00:00:00.000000000 Z
14
+ date: 2013-02-28 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rack
@@ -65,6 +65,8 @@ files:
65
65
  - README.markdown
66
66
  - Rakefile
67
67
  - bin/jetty-rackup
68
+ - examples/bind_to_specific_ip/app.rb
69
+ - examples/bind_to_specific_ip/config.ru
68
70
  - examples/issue4_handle400/app.rb
69
71
  - examples/issue4_handle400/config.ru
70
72
  - examples/just_ruby/app.rb