deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [1/2] git commit: Core: Added support for jruby Puma server
Date Fri, 01 Mar 2013 16:19:42 GMT
Core: Added support for jruby Puma server

The 'puma' web server is much faster and reliable
than java webrick.


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/07525157
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/07525157
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/07525157

Branch: refs/heads/master
Commit: 07525157137e7e13dba72f39a8dc0ef559fdb4f7
Parents: 75e3db4
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Mon Dec 10 15:31:04 2012 +0100
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Fri Mar 1 17:19:27 2013 +0100

----------------------------------------------------------------------
 server/Gemfile         |    1 +
 server/bin/deltacloudd |   24 +++++++++++++++++-------
 2 files changed, 18 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/07525157/server/Gemfile
----------------------------------------------------------------------
diff --git a/server/Gemfile b/server/Gemfile
index 4df57fe..bd56845 100644
--- a/server/Gemfile
+++ b/server/Gemfile
@@ -4,6 +4,7 @@ gemspec
 
 platforms :jruby do
   gem 'jruby-openssl'
+  gem 'puma'
 end
 
 group :development do

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/07525157/server/bin/deltacloudd
----------------------------------------------------------------------
diff --git a/server/bin/deltacloudd b/server/bin/deltacloudd
index 8cb8702..836bc55 100755
--- a/server/bin/deltacloudd
+++ b/server/bin/deltacloudd
@@ -178,7 +178,6 @@ if !options[:daemon] || options[:daemon] && !have_thin
     msg << ":: http://#{ENV["API_HOST"]}:#{ENV["API_PORT"]}/#{api_uri}"
   end
   puts msg
-  puts
 end
 
 if ENV['API_USER'] && ENV['API_PASSWORD']
@@ -192,11 +191,11 @@ unless have_thin
 
   puts "To start Deltacloud as a daemon, install 'thin' (gem install thin)\n\n" if options[:daemon]
 
+  port = ENV["API_PORT"].to_i
   # Read in config.ru and convert it to an instance of Rack::Builder
   cfgfile = File.read(File.join($top_srcdir, 'config.ru'))
   inner_app = eval("Rack::Builder.new {(" + cfgfile + "\n )}.to_app",
                    nil, 'config.ru')
-
   app = Rack::Builder.new {
     use Rack::CommonLogger # apache-like logging
     use Rack::Reloader #if options[:env] == "development"
@@ -208,11 +207,22 @@ unless have_thin
   port = ENV["API_PORT"].to_i
   puts "=> Ctrl-C to shutdown server"
   Dir::chdir($top_srcdir)
-  Rack::Server::start(:app => app,
-                      :server => :webrick,
-                      :Host => ENV["API_HOST"],
-                      :Port => port,
-                      :AccessLog => [])
+
+  if RUBY_PLATFORM == 'java'
+    require 'puma'
+    events = Puma::Events.new STDOUT, STDERR
+    server = Puma::Server.new app, events
+    server.add_tcp_listener ENV['API_HOST'], port
+    server.run(false)
+  else
+    # There's a bug with string ports on JRuby so convert to int
+    # http://jira.codehaus.org/browse/JRUBY-4868
+    puts "=> Ctrl-C to shutdown server"
+    Rack::Server::start(:app => app,
+                        :Host => ENV["API_HOST"],
+                        :Port => port,
+                        :AccessLog => [])
+  end
 else
   argv_opts = ARGV.clone
   argv_opts << ['start'] unless Thin::Runner.commands.include?(options[0])


Mime
View raw message