disbatch 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/disbatchd +33 -7
- data/lib/disbatch.rb +1 -1
- metadata +1 -1
data/bin/disbatchd
CHANGED
@@ -10,7 +10,7 @@ require 'trollop'
|
|
10
10
|
opts = Trollop.options do
|
11
11
|
opt 'config', 'the disbatchd config file', :default => '/etc/disbatch/disbatchd.conf'
|
12
12
|
opt 'max', 'maximum number of threads per queue', :default => 10
|
13
|
-
opt 'plugins', 'path(s) to dispatch plugins', :multi => true
|
13
|
+
opt 'plugins', 'path(s) to dispatch plugins', :multi => true, :type => :string
|
14
14
|
opt 'force', 'force node registration'
|
15
15
|
end
|
16
16
|
|
@@ -29,19 +29,45 @@ trap('TERM') { node.release; exit }
|
|
29
29
|
trap('INT') { node.release; exit }
|
30
30
|
trap('QUIT') { node.release; exit }
|
31
31
|
|
32
|
+
runners = {}
|
33
|
+
|
32
34
|
EventMachine::run do
|
33
35
|
|
34
|
-
|
36
|
+
EventMachine::add_periodic_timer(5) do
|
37
|
+
|
38
|
+
Disbatch::Queue.get_all.each do |queue|
|
39
|
+
|
40
|
+
# runner already exists
|
41
|
+
next if runners.has_key?(queue.id)
|
42
|
+
|
43
|
+
# node configured to ignore
|
44
|
+
# next if queue.nodes_ignore.include?(node.id)
|
45
|
+
|
46
|
+
# node pinned but not on this node
|
47
|
+
# next if !queue.nodes_ignore.empty? && !queue.nodes_ignore.include?(node.id)
|
48
|
+
|
49
|
+
# no plugin for queue
|
50
|
+
next unless Disbatch::Plugin[queue.plugin]
|
51
|
+
|
52
|
+
puts "Adding #{queue.plugin} runner for #{queue.id}"
|
35
53
|
|
36
|
-
|
54
|
+
runners[queue.id] = { 'tg' => ThreadGroup.new, 'queue' => queue }
|
37
55
|
|
38
|
-
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
runners.each do |id, runner|
|
60
|
+
puts "#{id}: #{runner['queue'].plugin}: #{runner['tg'].list.length}"
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
39
64
|
|
40
|
-
|
65
|
+
EventMachine::add_periodic_timer(1) do
|
41
66
|
|
42
|
-
|
67
|
+
runners.each do |id, runner|
|
43
68
|
|
44
|
-
|
69
|
+
tg = runner['tg']
|
70
|
+
queue = runner['queue']
|
45
71
|
|
46
72
|
next unless ((nt = tg.list.length) < max && (np = queue.length) > 0)
|
47
73
|
|
data/lib/disbatch.rb
CHANGED