Skip to content

Commit

Permalink
Merge branch 'master' into atmos
Browse files Browse the repository at this point in the history
Change-Id: I41461bc21142a0a4b8ae1c3d1aac80efbdba5f61
  • Loading branch information
figo committed Nov 3, 2011
2 parents 6588173 + e1c500f commit 9697f02
Show file tree
Hide file tree
Showing 263 changed files with 4,533 additions and 893 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
---
- Adam C. Greenfield { email: [email protected] }
- Ananthan Srinivasan { email: [email protected], name: AB}
- Andrew Liu { email: [email protected]}
- Christian Dupuis { email: [email protected]}
- Derek Collison { email: [email protected] }
- Ezra Zygmuntowicz { email: [email protected] }
Expand Down
5 changes: 5 additions & 0 deletions bin/cloud_controller
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ opts_parser = OptionParser.new do |opts|
end
opts_parser.parse!(ARGV.dup)

if $cc_config_file.nil? && ENV["CLOUD_FOUNDRY_CONFIG_PATH"]
$cc_config_file = File.join(ENV["CLOUD_FOUNDRY_CONFIG_PATH"], "cloud_controller.yml")
puts "Using config file #{$cc_config_file}"
end

if $cc_config_file
if File.exists?($cc_config_file)
ENV['CLOUD_CONTROLLER_CONFIG'] = $cc_config_file
Expand Down
3 changes: 3 additions & 0 deletions bin/config/redis-server.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bind 0.0.0.0
port 5454
loglevel debug
4 changes: 4 additions & 0 deletions bin/services/service_broker
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby
# Copyright (c) 2009-2011 VMware, Inc.

exec(File.expand_path("../../../services/service_broker/bin/service_broker", __FILE__), *ARGV)
4 changes: 4 additions & 0 deletions bin/stager
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby
# Copyright (c) 2009-2011 VMware, Inc.

exec(File.expand_path("../../stager/bin/stager", __FILE__), *ARGV)
71 changes: 66 additions & 5 deletions bin/vcap
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Component
end

def pid_file
configuration["pid"] || raise("#{@configuration_path} does not specify location of pid file")
configuration["pid"] || configuration['pid_filename'] || raise("#{@configuration_path} does not specify location of pid file")
end

def log_file?
Expand Down Expand Up @@ -136,7 +136,7 @@ class Component
# Make sure db is setup, this is slow and we should make it faster, but
# should help for now.
if is_cloud_controller?
Dir.chdir("#{File.dirname(__FILE__)}/../cloud_controller") { `rake db:migrate` }
Dir.chdir("#{File.dirname(__FILE__)}/../cloud_controller") { `bundle exec rake db:migrate CLOUD_CONTROLLER_CONFIG=#{@configuration_path}` }
end
exec("#{component_start_path}")
end
Expand Down Expand Up @@ -244,10 +244,64 @@ class NatsServer
end
end

class RedisServer
DEFAULT_CONFIG_PATH = File.expand_path('../config/redis-server.conf', __FILE__)

def initialize(pid_filename, config_path=DEFAULT_CONFIG_PATH)
@config_path = config_path
@pid_filename = pid_filename
@redis_path = `which redis-server`.chomp
unless $? == 0
STDERR.puts "Could not find redis-server, exiting.".red
exit 1
end
@pid = read_pidfile
end

def start
return if running?
@pid = fork do
log_file = File.join(TMP, 'redis-server.log')
stdout = File.open(log_file, 'a')
STDOUT.reopen(stdout)
stderr = File.open(log_file, 'a')
STDERR.reopen(stderr)
exec("#{@redis_path} #{@config_path}")
end
Process.detach(@pid)
File.open(@pid_filename, 'w+') {|f| f.write(@pid) }
end

def stop
return unless running?
Process.kill('TERM', @pid)
@pid = nil
end

private

def read_pidfile
if File.exist?(@pid_filename)
File.read(@pid_filename).chomp.to_i
else
nil
end
end

def running?
return false unless @pid
File.exist?(File.join('/proc', @pid.to_s))
end
end


module Run
DEFAULT_REDIS_PIDFILE = File.join(TMP, 'redis-server.pid')

def self.start_init
nats_server = NatsServer.new
nats_server.start_server
RedisServer.new(DEFAULT_REDIS_PIDFILE).start
end

def self.start(args)
Expand All @@ -259,6 +313,7 @@ module Run
# Only process this if no one else running..
running_components = components([]).select {|c| c.running?}.map{|c| c.name }
return unless running_components.empty?
RedisServer.new(DEFAULT_REDIS_PIDFILE).stop
nats_server = NatsServer.new
return unless nats_server.is_running?
nats_server.kill_server
Expand Down Expand Up @@ -289,7 +344,7 @@ module Run
end

cc_dir = File.expand_path(File.join(DIR, '..', 'cloud_controller'))
run_command("Resetting the CloudController database", "cd #{cc_dir} 2>&1 && rake db:drop 2>&1")
run_command("Resetting the CloudController database", "cd #{cc_dir} 2>&1 && bundle exec rake db:drop 2>&1")
puts

cc_log_dir = File.join(cc_dir, 'log')
Expand Down Expand Up @@ -380,7 +435,7 @@ module Run
private

def self.core
%w(router cloud_controller dea health_manager)
%w(router cloud_controller dea health_manager stager)
end

def self.services
Expand Down Expand Up @@ -424,7 +479,13 @@ module Run
args = (Run.core + Run.services) if args.empty?
args = Run.expand_args(args)
components = args.map do |arg|
component = Component.new(arg)
if $configdir
config_file = File.join($configdir, "#{arg}.yml")
if ! File.exists?(config_file)
config_file = nil
end
end
component = Component.new(arg, config_file)
component if component.exists?
end.compact
STDERR.puts "Don't know how to process '#{args.inspect}' \?\?" if components.empty?
Expand Down
10 changes: 7 additions & 3 deletions cloud_controller/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ gem 'logging', '>= 1.5.0'
# VCAP common components
gem 'vcap_common', :require => ['vcap/common', 'vcap/component'], :path => '../common'
gem 'vcap_logging', :require => ['vcap/logging']
gem 'vcap_staging', '= 0.1.24'

# XXX - Vendor once working
gem 'vcap_staging'
# For queuing staging tasks
gem 'em-hiredis'
gem 'vcap_stager', '= 0.1.3'

# Databases
gem 'sqlite3'
Expand All @@ -32,7 +34,7 @@ group :production do
end

# EventMachine and async support
gem 'eventmachine', '~> 0.12.10'
gem 'eventmachine', '~> 0.12.11.cloudfoundry.1'
gem 'thin', '> 1.2'
gem 'em-http-request', '~> 1.0.0.beta.3', :require => 'em-http'
gem 'em-redis', :require => nil
Expand All @@ -45,6 +47,7 @@ gem 'bcrypt-ruby', '>= 2.1.4'
gem 'ruby-hmac', :require => 'hmac-sha1'
gem 'SystemTimer', :platforms => :mri_18
gem 'uuidtools'
gem 'rest-client', '= 1.6.7'

# rspec-rails is outside the 'test' group in order to consistently provide Rake tasks.
gem 'rspec-rails', '>= 2.4.1'
Expand All @@ -54,5 +57,6 @@ group :test do
gem 'mocha'
gem 'ci_reporter'
gem 'sinatra' # For service gateway shims
gem 'delorean'
end

30 changes: 24 additions & 6 deletions cloud_controller/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PATH
remote: ../common
specs:
vcap_common (0.99)
eventmachine (~> 0.12.10)
eventmachine (~> 0.12.11.cloudfoundry.1)
logging (>= 1.5.0)
nats
posix-spawn
Expand Down Expand Up @@ -44,10 +44,15 @@ GEM
arel (2.0.9)
bcrypt-ruby (2.1.4)
builder (2.1.2)
chronic (0.6.4)
ci_reporter (1.6.4)
builder (>= 2.1.2)
daemons (1.1.2)
delorean (1.1.0)
chronic
diff-lcs (1.1.2)
em-hiredis (0.1.0)
hiredis (~> 0.3.0)
em-http-request (1.0.0.beta.3)
addressable (>= 2.2.3)
em-socksify
Expand All @@ -59,7 +64,8 @@ GEM
eventmachine
erubis (2.6.6)
abstract (>= 1.0.0)
eventmachine (0.12.10)
eventmachine (0.12.11.cloudfoundry.1)
hiredis (0.3.2)
http_parser.rb (0.5.1)
i18n (0.5.0)
json_pure (1.5.1)
Expand Down Expand Up @@ -103,6 +109,8 @@ GEM
thor (~> 0.14.4)
rake (0.8.7)
rcov (0.9.9)
rest-client (1.6.7)
mime-types (>= 1.16)
rspec (2.5.0)
rspec-core (~> 2.5.0)
rspec-expectations (~> 2.5.0)
Expand All @@ -119,7 +127,7 @@ GEM
ruby-hmac (0.4.0)
sinatra (1.2.1)
rack (~> 1.1)
tilt (< 2.0, >= 1.2.2)
tilt (>= 1.2.2, < 2.0)
sqlite3 (1.3.3)
thin (1.2.11)
daemons (>= 1.0.9)
Expand All @@ -132,7 +140,13 @@ GEM
tzinfo (0.3.26)
uuidtools (2.1.2)
vcap_logging (0.1.0)
vcap_staging (0.1.4)
vcap_stager (0.1.3)
vcap_staging (0.1.24)
nokogiri (>= 1.4.4)
rake
rspec
vcap_common
yajl-ruby (>= 0.7.9)
yajl-ruby (0.8.2)

PLATFORMS
Expand All @@ -142,9 +156,11 @@ DEPENDENCIES
SystemTimer
bcrypt-ruby (>= 2.1.4)
ci_reporter
delorean
em-hiredis
em-http-request (~> 1.0.0.beta.3)
em-redis
eventmachine (~> 0.12.10)
eventmachine (~> 0.12.11.cloudfoundry.1)
logging (>= 1.5.0)
mocha
mysql2 (>= 0.2.6)
Expand All @@ -154,6 +170,7 @@ DEPENDENCIES
rack-fiber_pool
rails (~> 3.0.5)
rcov
rest-client (= 1.6.7)
rspec (>= 2.4.0)
rspec-rails (>= 2.4.1)
ruby-hmac
Expand All @@ -163,5 +180,6 @@ DEPENDENCIES
uuidtools
vcap_common!
vcap_logging
vcap_staging
vcap_stager (= 0.1.3)
vcap_staging (= 0.1.24)
yajl-ruby (>= 0.7.9)
1 change: 0 additions & 1 deletion cloud_controller/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ def log_exception(e)
end

def render_cloud_error(e)
log_exception(e)
@error = e
render :status => e.status, :json => e.to_json
end
Expand Down
Loading

0 comments on commit 9697f02

Please sign in to comment.