Skip to content

Commit

Permalink
Merge pull request #785 from NREL/enqueue_to
Browse files Browse the repository at this point in the history
create new higher priority :requeued queue
  • Loading branch information
brianlball authored Aug 15, 2024
2 parents 2c150c7 + 7c24bc0 commit 5f50133
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docker-compose.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ services:
worker:
image: nrel/openstudio-server:latest
environment:
- QUEUES=simulations
- QUEUES=requeued,simulations
- COUNT=1
- REDIS_URL=${REDIS_URL}
- MONGO_USER=${MONGO_USER}
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ services:
rails_env: docker
environment:
- OS_SERVER_NUMBER_OF_WORKERS=${OS_SERVER_NUMBER_OF_WORKERS}
- QUEUES=simulations
- QUEUES=requeued,simulations
- COUNT=1
- REDIS_URL=${REDIS_URL}
- MONGO_USER=${MONGO_USER}
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ services:
bundle_args: ''
environment:
- OS_SERVER_NUMBER_OF_WORKERS=1
- QUEUES=simulations
- QUEUES=requeued,simulations
- COUNT=1
- REDIS_URL=${REDIS_URL}
- MONGO_USER=${MONGO_USER}
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ services:
rails_env: docker
environment:
- OS_SERVER_NUMBER_OF_WORKERS=${OS_SERVER_NUMBER_OF_WORKERS}
- QUEUES=simulations
- QUEUES=requeued,simulations
- COUNT=1
- REDIS_URL=${REDIS_URL}
- MONGO_USER=${MONGO_USER}
Expand Down
2 changes: 1 addition & 1 deletion local_setup_scripts/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ services:
worker:
image: 127.0.0.1:5000/openstudio-server
environment:
- QUEUES=simulations
- QUEUES=requeued,simulations
- COUNT=1
- REDIS_URL=redis://:openstudio@queue:6379
- MONGO_USER=openstudio
Expand Down
2 changes: 1 addition & 1 deletion local_setup_scripts/win64/docker-compose-mock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ services:
worker:
image: 127.0.0.1:5000/openstudio-server
environment:
- QUEUES=simulations
- QUEUES=requeued,simulations
- COUNT=1
- REDIS_URL=redis://:openstudio@queue:6379
- MONGO_USER=openstudio
Expand Down
2 changes: 1 addition & 1 deletion local_setup_scripts/win64/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ services:
worker:
image: 127.0.0.1:5000/openstudio-server
environment:
- QUEUES=simulations
- QUEUES=requeued,simulations
- COUNT=1
- REDIS_URL=redis://:openstudio@queue:6379
- MONGO_USER=openstudio
Expand Down
5 changes: 3 additions & 2 deletions server/app/controllers/data_points_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,11 @@ def requeue
Rails.logger.debug "data_points_contoller.id: #{@data_point.id}"
Rails.logger.debug "data_points_contoller.job_id: #{@data_point.job_id}"
# Destroy the existing job in Resque queue; this is tied to a worker_host:PID:uuid
Resque::Job.destroy(:requeue, 'ResqueJobs::RunSimulateDataPoint', @data_point.job_id)
Resque::Job.destroy(:simulations, 'ResqueJobs::RunSimulateDataPoint', @data_point.job_id)

# Enqueue a new job
Resque.enqueue(ResqueJobs::RunSimulateDataPoint, @data_point.job_id)
Resque.enqueue_to(:requeued, ResqueJobs::RunSimulateDataPoint, @data_point.job_id)

# Attempt to find the worker processing this job
#worker = find_resque_worker_by_job_id(@data_point.job_id)
Expand Down Expand Up @@ -342,7 +343,7 @@ def requeue_started

data_points_to_requeue.each do |dp|
Rails.logger.warn "Requeueing DataPoint #{dp.id}"
Resque.enqueue(ResqueJobs::RunSimulateDataPoint, dp.job_id)
Resque.enqueue_to(:requeued, ResqueJobs::RunSimulateDataPoint, dp.job_id)
end

respond_to do |format|
Expand Down
4 changes: 2 additions & 2 deletions server/app/jobs/resque_jobs/run_simulate_data_point.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ def self.perform(data_point_id, options = {})
rescue SignalException, Errno::ENOSPC, Resque::DirtyExit, Resque::TermException, Resque::PruneDeadWorkerDirtyExit => e
# Log the termination and re-enqueue attempt
d.add_to_rails_log("Worker Caught Exception: #{e.inspect}: Re-enqueueing DataPoint ID #{data_point_id}")
Resque.enqueue(self, data_point_id, options)
Resque.enqueue_to(:requeued, self, data_point_id, options)
puts "DataPoint #{data_point_id} re-enqueued."
rescue => e
d.add_to_rails_log("Worker Caught Unhandled Exception: #{e.message}: Re-enqueueing DataPoint ID #{data_point_id}")
Resque.enqueue(self, data_point_id, options)
Resque.enqueue_to(:requeued, self, data_point_id, options)
puts "Unhandled exception, re-enqueued DataPoint."
end
end
Expand Down
1 change: 1 addition & 0 deletions server/app/models/data_point.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def destroy_background_job
elsif Rails.application.config.job_manager == :resque
if job_id
Resque::Job.destroy(:simulations, 'ResqueJobs::RunSimulateDataPoint', job_id)
Resque::Job.destroy(:requeued, 'ResqueJobs::RunSimulateDataPoint', job_id)
end
else
raise 'Rails.application.config.job_manager must be set to :resque or :delayed_job'
Expand Down

0 comments on commit 5f50133

Please sign in to comment.