queue_dispatcher 1.5.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.rdoc +7 -0
- data/lib/queue_dispatcher/acts_as_task.rb +1 -1
- data/lib/queue_dispatcher/acts_as_task_queue.rb +3 -5
- data/lib/queue_dispatcher/message_sending.rb +1 -3
- data/lib/queue_dispatcher/psych_ext.rb +1 -1
- data/lib/queue_dispatcher/version.rb +1 -1
- data/queue_dispatcher.gemspec +6 -6
- data/script/queue_worker_dispatcher +15 -14
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MzhlMmZkNGQ0MDkxOTY5ZWViMzRlNWQ3YWVjMjY0ZWI0NGZmMDRhOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MWUzNmNhMmQ4OTgzNzJkODBkNTA4MzkyZmNiZTgzYmEyMzE1YTg3Nw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OGE1Y2QwOTBmNWNkNjYwZGU2ZTZjNWYxZTNmZDJiMmE2YjJkYmNmZmQxMDJk
|
10
|
+
ODEwM2UwNzIwYzAxMjBiM2VlZTFkOWZjYjY3N2RlZWExM2U1YmFiZjYyMGU4
|
11
|
+
YWRhZDFhNjNiZWYyMTFmZWViYTJjN2NlY2Y5ZGY4ODFhY2NkNDI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OGRlMDlhMWE1YzZjYTBkMGI2OWIyMWM3NTliMGE4MDE3NTk3ZGY4YmEzMjBi
|
14
|
+
NmUyZGI0ZjNjNGI5MmJjYzRhOGQ2NmE3ODIzODRjNjJlYzEwOTUxODAxNTc3
|
15
|
+
YmFjZmRlMDY3MDE3N2FhZTFkMTk5NDYxY2YxOTM0YWFjYzVlODE=
|
data/README.rdoc
CHANGED
@@ -23,6 +23,13 @@ Use
|
|
23
23
|
|
24
24
|
This will create a database migration for the models Task and TaskQueues.
|
25
25
|
|
26
|
+
If you update the queue_dispatcher from pre 1.5.1 you have to use the following command to update your migrations:
|
27
|
+
|
28
|
+
Use
|
29
|
+
rails g queue_dispatcher:migration --skip
|
30
|
+
|
31
|
+
This will create all new database migrations for the models Task and TaskQueues and leve the existing as they are.
|
32
|
+
|
26
33
|
=== Gem Dependencies
|
27
34
|
|
28
35
|
Please check if all those requirements are satisfied on your environment.
|
@@ -24,7 +24,7 @@ module QueueDispatcher
|
|
24
24
|
|
25
25
|
@acts_as_task_config = QueueDispatcher::ActsAsTask::Config.new(args[:task_queue_model] || :task_queue)
|
26
26
|
|
27
|
-
belongs_to acts_as_task_config.task_queue_class_name
|
27
|
+
belongs_to acts_as_task_config.task_queue_class_name.to_sym
|
28
28
|
has_many :task_dependencies, :dependent => :destroy, :foreign_key => :task_id
|
29
29
|
has_many :dependent_tasks, :through => :task_dependencies
|
30
30
|
has_many :inverse_task_dependencies, :class_name => 'TaskDependency', :foreign_key => 'dependent_task_id', :dependent => :destroy
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'sys/proctable'
|
2
2
|
require 'queue_dispatcher/rc_and_msg'
|
3
|
-
require 'spawn'
|
4
3
|
|
5
4
|
module QueueDispatcher
|
6
5
|
module ActsAsTaskQueue
|
@@ -33,7 +32,6 @@ module QueueDispatcher
|
|
33
32
|
|
34
33
|
module ClassMethods
|
35
34
|
def acts_as_task_queue(args = {})
|
36
|
-
include Spawn
|
37
35
|
include ActionView::Helpers::UrlHelper
|
38
36
|
include QdLogger
|
39
37
|
|
@@ -42,7 +40,7 @@ module QueueDispatcher
|
|
42
40
|
|
43
41
|
@acts_as_task_queue_config = QueueDispatcher::ActsAsTaskQueue::Config.new(args)
|
44
42
|
|
45
|
-
has_many acts_as_task_queue_config.task_class_name.pluralize,
|
43
|
+
has_many acts_as_task_queue_config.task_class_name.pluralize.to_sym, -> { order(:priority, :id) }
|
46
44
|
serialize :interrupts, Array
|
47
45
|
end
|
48
46
|
end
|
@@ -127,7 +125,7 @@ module QueueDispatcher
|
|
127
125
|
# Find next pending task, where all dependent tasks are executed
|
128
126
|
all_tasks = acts_as_task_queue_tasks.lock(true).all
|
129
127
|
pos = 0
|
130
|
-
while task.nil? && pos < all_tasks.count do
|
128
|
+
while task.nil? && pos < all_tasks.to_a.count do
|
131
129
|
t = all_tasks[pos]
|
132
130
|
if t.dependent_tasks_executed?
|
133
131
|
task = t if t.state == 'new'
|
@@ -485,7 +483,7 @@ module QueueDispatcher
|
|
485
483
|
# Interrupt handler
|
486
484
|
def handle_interrupts(args = {})
|
487
485
|
interrupts.each { |int| send int.to_sym }
|
488
|
-
update_attributes interrupts
|
486
|
+
update_attributes :interrupts => []
|
489
487
|
rescue => exception
|
490
488
|
backtrace = exception.backtrace.join("\n ")
|
491
489
|
log :msg => "Fatal error in method 'handle_interrupts': #{$!}\n #{backtrace}", :sev => :error, :print_log => args[:print_log]
|
@@ -88,7 +88,7 @@ module Psych
|
|
88
88
|
payload = Hash[*object.children.map { |c| accept c }]
|
89
89
|
id = payload["attributes"][klass.primary_key]
|
90
90
|
begin
|
91
|
-
if ActiveRecord::VERSION::MAJOR
|
91
|
+
if ActiveRecord::VERSION::MAJOR >= 3
|
92
92
|
klass.unscoped.find(id)
|
93
93
|
else # Rails 2
|
94
94
|
klass.with_exclusive_scope { klass.find(id) }
|
data/queue_dispatcher.gemspec
CHANGED
@@ -12,12 +12,12 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.summary = %q{This Gem installs a queue dispatcher for handling asynchronous tasks}
|
13
13
|
s.description = %q{Queue_Dispatcher executes asynchronous tasks in the background.}
|
14
14
|
|
15
|
-
s.add_dependency
|
16
|
-
s.add_dependency
|
17
|
-
s.add_dependency
|
18
|
-
s.add_dependency
|
19
|
-
s.add_dependency
|
20
|
-
s.add_dependency
|
15
|
+
s.add_dependency 'sys-proctable', '>= 0.9.1'
|
16
|
+
s.add_dependency 'deadlock_retry'
|
17
|
+
s.add_dependency 'spawnling'
|
18
|
+
s.add_dependency 'haml'
|
19
|
+
s.add_dependency 'will_paginate'
|
20
|
+
s.add_dependency 'jquery-rails'
|
21
21
|
|
22
22
|
s.files = `git ls-files`.split("\n")
|
23
23
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -1,16 +1,15 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# BEGIN - rails runner… with a relative path
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
load 'rails'
|
3
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
4
|
+
require File.expand_path('../../config/boot', __FILE__)
|
5
|
+
require APP_PATH
|
6
|
+
# set Rails.env here if desired
|
7
|
+
Rails.application.require_environment!
|
9
8
|
# END - rails runner… with a relative path
|
10
9
|
|
11
10
|
require 'sys/proctable'
|
11
|
+
require 'spawnling'
|
12
12
|
include Sys
|
13
|
-
include Spawn
|
14
13
|
include IwLogger
|
15
14
|
|
16
15
|
|
@@ -107,8 +106,10 @@ end
|
|
107
106
|
# Install signal handler for worker
|
108
107
|
def worker_install_signal_handler
|
109
108
|
install_signal_handler(['TERM'], :trap_msg => "Caught trap signal. Shutdown...", :ignore_signals => ['HUP', 'INT']) do
|
110
|
-
# Shutdown task_queue
|
111
|
-
|
109
|
+
# Shutdown task_queue. Because of Ruby 2.0, we have to do this in a Thread to prevent "can't be called from trap context"-errors!
|
110
|
+
Thread.new do
|
111
|
+
$worker[:task_queue].update_attributes state: 'shutdown' if $worker[:task_queue]
|
112
|
+
end
|
112
113
|
$worker[:work] = false
|
113
114
|
end
|
114
115
|
end
|
@@ -145,7 +146,7 @@ def daemon_start
|
|
145
146
|
|
146
147
|
daemon_log :msg => "Starting process..."
|
147
148
|
if $daemon[:background]
|
148
|
-
|
149
|
+
Spawnling.new { daemon_runner }
|
149
150
|
else
|
150
151
|
daemon_runner
|
151
152
|
end
|
@@ -159,7 +160,7 @@ def spawn_and_monitor_workers
|
|
159
160
|
while $daemon[:work]
|
160
161
|
# (Re)start workers
|
161
162
|
while $daemon[:worker_pids].count < $daemon[:worker_count] do
|
162
|
-
sp =
|
163
|
+
sp = Spawnling.new(:argv => $worker[:process_prefix]) do
|
163
164
|
worker_runner
|
164
165
|
end
|
165
166
|
$daemon[:worker_pids] << sp.handle
|
@@ -231,8 +232,8 @@ end
|
|
231
232
|
def daemon_parse_opts
|
232
233
|
start = true
|
233
234
|
|
234
|
-
unless
|
235
|
-
case
|
235
|
+
unless ARGV.length == 0
|
236
|
+
case ARGV[0]
|
236
237
|
when '-b', '--background'
|
237
238
|
$daemon[:background] = true;
|
238
239
|
|
@@ -245,7 +246,7 @@ def daemon_parse_opts
|
|
245
246
|
start = false
|
246
247
|
|
247
248
|
else
|
248
|
-
puts "Invalid argument: #{
|
249
|
+
puts "Invalid argument: #{ARGV[0]}" if !ARGV[0].nil?
|
249
250
|
daemon_show_usage
|
250
251
|
start = false
|
251
252
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: queue_dispatcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philip Kurmann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sys-proctable
|
@@ -39,19 +39,19 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: spawnling
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ! '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: haml
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|