Skip to content

Commit

Permalink
bugfix: switch from using backticks for calling rake tasks to the mor…
Browse files Browse the repository at this point in the history
…e standard way. No longer relies on the rake executable, and therefore we no longer need the ENV['PATH'] fix.
  • Loading branch information
Kieran Pilkington committed Dec 20, 2009
1 parent f982532 commit b24f085
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions app/controllers/configure_controller.rb
Expand Up @@ -131,7 +131,7 @@ def zoom_dbs_update
if @zoom_dbs.all? { |zoom_db| zoom_db.errors.empty? and !@kete_password.blank? }

ENV['ZEBRA_PASSWORD'] = @kete_password
Rails.logger.info `rake zebra:set_keteaccess`
Rails.logger.info Rake::Task["zebra:set_keteaccess"].execute(ENV)

@zoom_dbs.each do |zoom_db|
zoom_db.save!
Expand All @@ -145,7 +145,7 @@ def zoom_dbs_update
end
end

Rails.logger.info `rake zebra:set_ports`
Rails.logger.info Rake::Task["zebra:set_ports"].execute(ENV)
ENV.delete 'PUBLIC_PORT'
ENV.delete 'PRIVATE_PORT'

Expand Down
9 changes: 0 additions & 9 deletions config/environment.rb
Expand Up @@ -24,15 +24,6 @@
# which causes rails to bug out that it can't find the module
# require File.join(File.dirname(__FILE__) + '/initializers/', 'oai_pmh')

# Kieran Pilkington, 2009-12-18
# Apache doesn't take environment variables from any bashrc file
# So if we use Ruby Enterprise Edition, it'll never find ruby/rake
# Until Passenger automatically corrects this, we can use Apache
# SetEnv function to pass in a variable from the configurations
# We get that variable and append it to the environment here so
# calls like `rake zebra:start` work properly
ENV['PATH'] = "#{ENV['RUBY_INSTALL_PATH']}/bin:#{ENV['PATH']}" if ENV['RUBY_INSTALL_PATH']

# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')

Expand Down
20 changes: 14 additions & 6 deletions lib/workers/zoom_index_rebuild_worker.rb
Expand Up @@ -54,26 +54,34 @@ def do_work(args = nil)
raise "Start must be a valid item id number." if @start_id != 'first' && @start_id.to_i == 0
raise "End must be a valid item id number." if @end_id != 'last' && @end_id.to_i == 0

# Rake::Task is available inside Rails, but not backgroundrb workers
# so we need to include rake and load the task(s) we need to use
require 'rake'
load File.join(Rails.root, 'lib', 'tasks', 'zebra.rake')

# reset the zebra dbs to no records
# the zebra:stop task is problematic on some platforms (known issue with solaris 10)
# so you may want to do this bit by hand (before you request that this worker starts)
if @clear_zebra
logger.info("in clear zebra")
`rake zebra:init`
# do the private zebra db, too if we should
`rake zebra:init ZEBRA_DB=private` unless @skip_private
Rake::Task["zebra:init"].execute(ENV)
# do the private zebra db, too if we should`rake zebra:init`
unless @skip_private
ENV['ZEBRA_DB'] = 'private'
Rake::Task["zebra:init"].execute(ENV)
end

# we stop and start zebra so that any changes to configuration files
# (maybe the case with upgrades)
# are loaded
`rake zebra:stop`
`rake zebra:start`
Rake::Task["zebra:stop"].execute(ENV)
Rake::Task["zebra:start"].execute(ENV)
end

# add the bootstrap records
# we always do this to handle upgrades (before the bootstrap records existed)
# the rake task will skip the records if they already exist
`rake zebra:load_initial_records`
Rake::Task["zebra:load_initial_records"].execute(ENV)

clause = "id >= :start_id"
clause_values = Hash.new
Expand Down

0 comments on commit b24f085

Please sign in to comment.