Return-Path: Delivered-To: apmail-incubator-deltacloud-dev-archive@minotaur.apache.org Received: (qmail 58890 invoked from network); 21 Oct 2010 22:42:37 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 21 Oct 2010 22:42:37 -0000 Received: (qmail 97039 invoked by uid 500); 21 Oct 2010 22:42:37 -0000 Delivered-To: apmail-incubator-deltacloud-dev-archive@incubator.apache.org Received: (qmail 97012 invoked by uid 500); 21 Oct 2010 22:42:37 -0000 Mailing-List: contact deltacloud-dev-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-dev@incubator.apache.org Received: (qmail 96999 invoked by uid 99); 21 Oct 2010 22:42:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Oct 2010 22:42:37 +0000 X-ASF-Spam-Status: No, hits=-5.0 required=10.0 tests=RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lutter@redhat.com designates 209.132.183.28 as permitted sender) Received: from [209.132.183.28] (HELO mx1.redhat.com) (209.132.183.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Oct 2010 22:42:30 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9LMgA9w001283 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 21 Oct 2010 18:42:10 -0400 Received: from avon.watzmann.net (ovpn-113-106.phx2.redhat.com [10.3.113.106]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o9LMg90d001575 for ; Thu, 21 Oct 2010 18:42:09 -0400 From: lutter@redhat.com To: deltacloud-dev@incubator.apache.org Subject: [PATCH 1/2] * server/bin/deltacloudd: fall back to WebRick if thin isn't there Date: Thu, 21 Oct 2010 15:42:01 -0700 Message-Id: <1287700922-13298-2-git-send-email-lutter@redhat.com> In-Reply-To: <1287700922-13298-1-git-send-email-lutter@redhat.com> References: <1287700922-13298-1-git-send-email-lutter@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 From: David Lutterkort 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. --- server/bin/deltacloudd | 32 +++++++++++++++++--------------- 1 files changed, 17 insertions(+), 15 deletions(-) diff --git a/server/bin/deltacloudd b/server/bin/deltacloudd index 9d91e1a..ed7883b 100755 --- a/server/bin/deltacloudd +++ b/server/bin/deltacloudd @@ -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["API_DRIVER"]} :: http://#{ENV["API_HOST" 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__), "..")) -- 1.7.2.3