disbatch 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/disbatchd +33 -7
  2. data/lib/disbatch.rb +1 -1
  3. 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
- queues = Disbatch::Queue.get_all
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
- queues.each do |queue|
54
+ runners[queue.id] = { 'tg' => ThreadGroup.new, 'queue' => queue }
37
55
 
38
- next unless Disbatch::Plugin[queue.plugin]
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
- puts "Adding #{queue.plugin} runner for #{queue.id}"
65
+ EventMachine::add_periodic_timer(1) do
41
66
 
42
- tg = ThreadGroup.new
67
+ runners.each do |id, runner|
43
68
 
44
- EventMachine::add_periodic_timer(0.1) do
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
@@ -1,7 +1,7 @@
1
1
  module Disbatch
2
2
 
3
3
  # engine version
4
- VERSION = 'rdisbatch 0.0.7'
4
+ VERSION = 'rdisbatch 0.0.8'
5
5
  # specification version
6
6
  SPEC_VERSION = '1.9'
7
7
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: disbatch
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.7
5
+ version: 0.0.8
6
6
  platform: ruby
7
7
  authors:
8
8
  - Matthew Berg