Sha256: 55153fd5f51d52023090ce156529bd02b1a76f93b387029fcbd694386c2cf841
Contents?: true
Size: 665 Bytes
Versions: 1
Compression:
Stored size: 665 Bytes
Contents
module FakeServiceBus class Daemonize attr_reader :pid def initialize(options) @pid = options.fetch(:pid) { warn "No PID file specified while daemonizing!" exit 1 } end def call Process.daemon(true, true) if File.exist?(pid) existing_pid = File.open(pid, 'r').read.chomp.to_i running = Process.getpgid(existing_pid) rescue false if running warn "Error, Process #{existing_pid} already running" exit 1 else warn "Cleaning up stale pid at #{pid}" end end File.open(pid, 'w') { |f| f.write(Process.pid) } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fake_servicebus-0.0.2 | lib/fake_servicebus/daemonize.rb |