added hook for resque

This commit is contained in:
Vokhmin Alexey V 2013-10-25 17:24:59 +04:00
parent 6172d27a7b
commit 5f0938bf06
2 changed files with 14 additions and 10 deletions

View File

@ -15,10 +15,11 @@ class Api::V1::JobsController < Api::V1::BaseController
oldest.order(:created_at)
build_lists = build_lists.for_platform(platform_ids) if platform_ids.present?
if current_user.system?
# TODO: rollback later
# @build_list = build_lists.not_owned_external_nodes.first
@build_list = build_lists.external_nodes(:everything).first
@build_list = build_lists.not_owned_external_nodes.first
# TODO: Hook for resque, remove later
if @build_list && @build_list.external_nodes.blank? && @build_list.destroy_from_resque_queue != 1
@build_list = nil
end
@build_list.touch if @build_list
else
@build_list = build_lists.external_nodes(:owned).for_user(current_user).first

View File

@ -29,12 +29,7 @@ module AbfWorker::ModelHelper
end
def cancel_job
deleted = Resque::Job.destroy(
worker_queue_with_priority,
worker_queue_class,
abf_worker_args
)
if deleted == 1
if destroy_from_resque_queue == 1
build_canceled
else
send_stop_signal
@ -42,6 +37,14 @@ module AbfWorker::ModelHelper
true
end
def destroy_from_resque_queue
Resque::Job.destroy(
worker_queue_with_priority,
worker_queue_class,
abf_worker_args
)
end
def worker_queue_with_priority(queue = nil)
queue ||= abf_worker_base_queue
queue << '_' << abf_worker_priority if abf_worker_priority.present?