Return-Path: Delivered-To: apmail-incubator-deltacloud-commits-archive@minotaur.apache.org Received: (qmail 39624 invoked from network); 22 Oct 2010 08:13:27 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 22 Oct 2010 08:13:27 -0000 Received: (qmail 81791 invoked by uid 500); 22 Oct 2010 08:13:27 -0000 Delivered-To: apmail-incubator-deltacloud-commits-archive@incubator.apache.org Received: (qmail 81765 invoked by uid 500); 22 Oct 2010 08:13:27 -0000 Mailing-List: contact deltacloud-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: deltacloud-dev@incubator.apache.org Delivered-To: mailing list deltacloud-commits@incubator.apache.org Received: (qmail 81758 invoked by uid 99); 22 Oct 2010 08:13:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 Oct 2010 08:13:26 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 Oct 2010 08:13:24 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 8F0C723889F1; Fri, 22 Oct 2010 08:12:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1026236 - /incubator/deltacloud/trunk/server/bin/deltacloudd Date: Fri, 22 Oct 2010 08:12:27 -0000 To: deltacloud-commits@incubator.apache.org From: mfojtik@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101022081227.8F0C723889F1@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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__), ".."))