Sha256: d079e8ef4924acb0a6a07727f9f8011904541fdd6d5c907782455a07d2eaef9b
Contents?: true
Size: 618 Bytes
Versions: 26
Compression:
Stored size: 618 Bytes
Contents
# This will ride alongside god and kill any rogue stale worker # processes. Their sacrifice is for the greater good. WORKER_TIMEOUT = 60 * 10 # 10 minutes Thread.new do loop do begin `ps -e -o pid,command | grep [r]esque`.split("\n").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 ::Process.kill('USR1', parts[0].to_i) end end rescue # don't die because of stupid exceptions nil end sleep 30 end end
Version data entries
26 entries across 26 versions & 6 rubygems