kthxbye 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module Kthxbye
2
2
  # Returns current version of Kthxbye
3
- Version = VERSION = "1.1.0"
3
+ Version = VERSION = "1.1.1"
4
4
  end
5
5
 
@@ -93,10 +93,28 @@ module Kthxbye
93
93
 
94
94
  # Run startup actions
95
95
  def startup #:nodoc:
96
+ clean_workers
96
97
  register_worker
97
98
  register_signals
98
99
  end
99
100
 
101
+ # This method cleans Redis of all workers that no longer exist that may have
102
+ # been left over from a previous dirty shutdown (GC)
103
+ def clean_workers
104
+ workers = Kthxbye.workers
105
+ known = worker_pids
106
+ puts workers
107
+ puts known
108
+ workers.each do |worker|
109
+ host,pid,queues = worker.id.split(":")
110
+ next unless host == hostname
111
+ next if known.include?(pid)
112
+ log "Pruning unknown worker: #{worker}"
113
+ worker.unregister_worker
114
+ end
115
+
116
+ end
117
+
100
118
  # Adds this worker to the worker registry
101
119
  def register_worker
102
120
  log "Registered worker #{self}"
@@ -221,6 +239,14 @@ module Kthxbye
221
239
  Process.pid
222
240
  end
223
241
 
242
+ # Returns an array of string pids of all the other workers on this
243
+ # machine. Useful when pruning dead workers on startup.
244
+ def worker_pids
245
+ `ps -A -o pid,command | grep kthxbye`.split("\n").map do |line|
246
+ line.split(' ')[0]
247
+ end
248
+ end
249
+
224
250
  # Returns a useful id with the hostname:pid:queues listing
225
251
  # Same return as to_s
226
252
  def id
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kthxbye
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 17
4
5
  prerelease: false
5
6
  segments:
6
7
  - 1
7
8
  - 1
8
- - 0
9
- version: 1.1.0
9
+ - 1
10
+ version: 1.1.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Luke van der Hoeven
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-10-05 00:00:00 -04:00
18
+ date: 2010-10-06 00:00:00 -04:00
18
19
  default_executable:
19
20
  dependencies: []
20
21
 
@@ -84,6 +85,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
84
85
  requirements:
85
86
  - - ">="
86
87
  - !ruby/object:Gem::Version
88
+ hash: 3
87
89
  segments:
88
90
  - 0
89
91
  version: "0"
@@ -92,6 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
94
  requirements:
93
95
  - - ">="
94
96
  - !ruby/object:Gem::Version
97
+ hash: 23
95
98
  segments:
96
99
  - 1
97
100
  - 3