This is so that it can properly fetch the value of RAILS_ENV and access the correct database.
Signed-off-by: Chris Lalancette <[email protected]> --- conf/deltacloud-rails.sysconf | 5 ++++- deltacloud-aggregator.spec.in | 1 + src/classad_plugin/classad_plugin.rb | 15 +++++++++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/conf/deltacloud-rails.sysconf b/conf/deltacloud-rails.sysconf index bc9e237..6f87ec9 100644 --- a/conf/deltacloud-rails.sysconf +++ b/conf/deltacloud-rails.sysconf @@ -1,3 +1,6 @@ # sets ruby on Rails environment / mode of operation # http://wiki.rubyonrails.org/rails/pages/Environments -#RAILS_ENV=production +# +# NOTE: This needs to be set to some value in order for all of the +# daemons to access the same database +export RAILS_ENV=production diff --git a/deltacloud-aggregator.spec.in b/deltacloud-aggregator.spec.in index 63824cf..da101d3 100644 --- a/deltacloud-aggregator.spec.in +++ b/deltacloud-aggregator.spec.in @@ -23,6 +23,7 @@ Requires: rubygem(daemons) Requires: rubygem(haml) Requires: rubygem(nokogiri) >= 1.4.0 Requires: rubygem(will_paginate) +Requires: rubygem(parseconfig) Requires: postgresql Requires: postgresql-server Requires: ruby-postgres diff --git a/src/classad_plugin/classad_plugin.rb b/src/classad_plugin/classad_plugin.rb index 17beea9..5ac4b09 100644 --- a/src/classad_plugin/classad_plugin.rb +++ b/src/classad_plugin/classad_plugin.rb @@ -8,13 +8,24 @@ require 'instance' require 'cloud_account' require 'pool' require 'quota' +require 'parseconfig' def classad_plugin(logf, conf_path, instance_key, account_id) - ENV['RAILS_ENV'] = 'development' unless ENV['RAILS_ENV'] + rails_env = "development" + begin + config = ParseConfig.new('/etc/sysconfig/deltacloud-rails') + env = config.get_value("RAILS_ENV") + if not env.nil? + rails_env = env + end + rescue + # if any of this failed, then just assume the development database and + # hope for the best + end logf.puts "loading db config from #{conf_path}" conf = YAML::load(File.open(conf_path)) - ActiveRecord::Base.establish_connection(conf[ENV['RAILS_ENV']]) + ActiveRecord::Base.establish_connection(conf[rails_env]) # I left the puts in here because you can run condor_negotiator -f from the # command line and it will print this stuff out. Very nice for debugging. -- 1.7.2.3 _______________________________________________ deltacloud-devel mailing list [email protected] https://fedorahosted.org/mailman/listinfo/deltacloud-devel
