incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject svn commit: r962245 - /incubator/deltacloud/trunk/server/bin/deltacloudd
Date Thu, 08 Jul 2010 23:40:37 GMT
Author: lutter
Date: Thu Jul  8 23:40:37 2010
New Revision: 962245

URL: http://svn.apache.org/viewvc?rev=962245&view=rev
Log:
* bin/deltacloudd: set API_* environment variables

Commit f9dfecfe did not set API_DRIVER, API_HOST or API_PORT, so that we
were always running the mock driver on localhost:3001

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=962245&r1=962244&r2=962245&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/bin/deltacloudd (original)
+++ incubator/deltacloud/trunk/server/bin/deltacloudd Thu Jul  8 23:40:37 2010
@@ -5,9 +5,7 @@ require 'optparse'
 require 'thin'
 
 options = {
-  :env => 'development',
-  :host => 'localhost',
-  :port => '3001'
+  :env => 'development'
 }
 optparse = OptionParser.new do |opts|
 
@@ -17,9 +15,16 @@ deltacloudd -i <driver> [options]
 
 Options:
 BANNER
-  opts.on( '-i', '--driver DRIVER', 'Driver to use') { |driver| options[:driver] = driver
}
-  opts.on( '-r', '--hostname HOSTNAME', 'Bind to HOST address (default: localhost)') { |host|
options[:host] = host }
-  opts.on( '-p', '--port PORT', 'Use PORT (default: 3000)') { |port| options[:port] = port
}
+  opts.on( '-i', '--driver DRIVER', 'Driver to use') do |driver|
+    ENV["API_DRIVER"] = driver
+  end
+  opts.on( '-r', '--hostname HOSTNAME',
+           'Bind to HOST address (default: localhost)') do |host|
+    ENV["API_HOST"] = host
+  end
+  opts.on( '-p', '--port PORT', 'Use PORT (default: 3001)') do |port|
+    ENV["API_PORT"] = port
+  end
   opts.on( '-e', '--env ENV', 'Environment (default: "development")') { |env| options[:env]
= env }
   opts.on( '-h', '--help', '') { options[:help] = true }
 end
@@ -31,17 +36,20 @@ if options[:help]
  exit(0)
 end
 
-unless options[:driver]
+unless ENV["API_DRIVER"]
   puts "You need to specify a driver to use (-i <driver>)"
   exit(1)
 end
 
+ENV["API_HOST"] = "localhost" unless ENV["API_HOST"]
+ENV["API_PORT"] = "3001" unless ENV["API_PORT"]
+
 dirname="#{File.dirname(__FILE__)}/.."
 
 argv_opts = ARGV.clone
 argv_opts << ['start'] unless Thin::Runner.commands.include?(options[0])
-argv_opts << ['--address', options[:host] ]
-argv_opts << ['--port', options[:port] ]
+argv_opts << ['--address', ENV["API_HOST"] ]
+argv_opts << ['--port', ENV["API_PORT"] ]
 argv_opts << ['--rackup', 'config.ru' ]
 argv_opts << ['--chdir', dirname ]
 argv_opts << ['-e', options[:env] ]
@@ -52,10 +60,9 @@ argv_opts.flatten!
 thin = Thin::Runner.new(argv_opts)
 
 begin
-  puts "Starting Deltacloud API :: #{options[:driver]} :: http://#{options[:host]}:#{options[:port]}/api"
+  puts "Starting Deltacloud API :: #{ENV["API_DRIVER"]} :: http://#{ENV["API_HOST"]}:#{ENV["API_PORT"]}/api"
   puts
   thin.run!
 rescue Exception => e
   puts "ERROR: #{e.message}"
 end
-



Mime
View raw message