Permalink
Browse files

added exemptions to stale.god

  • Loading branch information...
1 parent 0569a1e commit 23705747b9e0c6d4f4dd2ad594a1f49623fcfe6b @clifton clifton committed with steveklabnik Nov 11, 2011
Showing with 6 additions and 1 deletion.
  1. +6 −1 examples/god/stale.god
View
@@ -2,17 +2,22 @@
# processes. Their sacrifice is for the greater good.
WORKER_TIMEOUT = 60 * 10 # 10 minutes
+STALE_EXEMPTIONS = ["imports"]
Thread.new do
loop do
begin
- `ps -e -o pid,command | grep [r]esque`.split("\n").each do |line|
+ lines = `ps -e -o pid,command | grep [r]esque`.split("\n")
+ lines.each do |line|
parts = line.split(' ')
next if parts[-2] != "at"
started = parts[-1].to_i
elapsed = Time.now - Time.at(started)
if elapsed >= WORKER_TIMEOUT
+ parent = lines.detect { |line| line.split(" ").first == parts[3] }
+ queue = parent.split(" ")[3]
+ next if STALE_EXEMPTIONS.include?(queue)
::Process.kill('USR1', parts[0].to_i)
end
end

0 comments on commit 2370574

Please sign in to comment.