incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject svn commit: r1026236 - /incubator/deltacloud/trunk/server/bin/deltacloudd
Date Fri, 22 Oct 2010 08:12:27 GMT
Author: mfojtik
Date: Fri Oct 22 08:12:27 2010
New Revision: 1026236

URL: http://svn.apache.org/viewvc?rev=1026236&view=rev
Log:
* server/bin/deltacloudd: fall back to WebRick if thin isn't there

Rather than use WebRick only on the Java platform, check whether thin is
there, und decide whether to start thin or WebRick depending on whether
thin is there.

Modified:
    incubator/deltacloud/trunk/server/bin/deltacloudd

Modified: incubator/deltacloud/trunk/server/bin/deltacloudd
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/bin/deltacloudd?rev=1026236&r1=1026235&r2=1026236&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/bin/deltacloudd (original)
+++ incubator/deltacloud/trunk/server/bin/deltacloudd Fri Oct 22 08:12:27 2010
@@ -3,6 +3,18 @@
 require 'rubygems'
 require 'optparse'
 
+# See if we can require +name+ and return +true+ if the library is there,
+# +false+ otherwise. Note that, as a side effect, the library will be
+# loaded
+def library_present?(name)
+  begin
+    require name
+    true
+  rescue LoadError
+    false
+  end
+end
+
 options = {
   :env => 'development'
 }
@@ -47,9 +59,11 @@ puts "Starting Deltacloud API :: #{ENV["
 puts
 
 dirname="#{File.dirname(__FILE__)}/.."
-platform = RUBY_PLATFORM[/java/] || 'ruby'
 
-if platform == 'java'
+have_thin = library_present?('thin')
+have_rerun = library_present?('rerun')
+
+unless have_thin
   require 'rack'
 
   # We can't chdir with webrick so add our root directory
@@ -78,8 +92,6 @@ if platform == 'java'
                              :Port => port,
                              :AccessLog => [])
 else
-  require 'thin'
-
   argv_opts = ARGV.clone
   argv_opts << ['start'] unless Thin::Runner.commands.include?(options[0])
   argv_opts << ['--address', ENV["API_HOST"] ]
@@ -91,17 +103,7 @@ else
 
   argv_opts.flatten!
 
-  if options[:env] == "development"
-    use_rerun = false
-    begin
-      require "rerun"
-      use_rerun = true
-    rescue
-      # Do nothing
-    end
-  end
-
-  if use_rerun
+  if have_rerun && options[:env] == "development"
     argv_opts.unshift "thin"
     command = argv_opts.join(" ")
     topdir = File::expand_path(File::join(File::dirname(__FILE__), ".."))



Mime
View raw message