Skip to content

Commit 97d0029

Browse files
cliftonsteveklabnik
authored andcommitted
added exemptions to stale.god
1 parent 502cd86 commit 97d0029

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

examples/god/stale.god

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,22 @@
22
# processes. Their sacrifice is for the greater good.
33

44
WORKER_TIMEOUT = 60 * 10 # 10 minutes
5+
STALE_EXEMPTIONS = ["imports"]
56

67
Thread.new do
78
loop do
89
begin
9-
`ps -e -o pid,command | grep [r]esque`.split("\n").each do |line|
10+
lines = `ps -e -o pid,command | grep [r]esque`.split("\n")
11+
lines.each do |line|
1012
parts = line.split(' ')
1113
next if parts[-2] != "at"
1214
started = parts[-1].to_i
1315
elapsed = Time.now - Time.at(started)
1416

1517
if elapsed >= WORKER_TIMEOUT
18+
parent = lines.detect { |line| line.split(" ").first == parts[3] }
19+
queue = parent.split(" ")[3]
20+
next if STALE_EXEMPTIONS.include?(queue)
1621
::Process.kill('USR1', parts[0].to_i)
1722
end
1823
end

0 commit comments

Comments
 (0)