pidly
Description
Pidly is a very minimalistic daemon library that doesn't make assumptions. Pidly allows you to control the daemon without getting in the way with forced verbose output and usage messages.
Examples
require 'pidly'
class Test < Pidly::Control
before_start do
puts "BEFORE START #{@pid}"
end
start :when_daemon_starts
stop do
puts "Attempting to kill process: #{@pid}"
end
after_stop :test_after_daemon_stops
error do
puts "SENDING EMAIL | Error Count: #{@error_count}"
end
def when_daemon_starts
loop do
print "TEST FROM #{@pid}"
sleep 2
end
end
end
@daemon = Test.spawn(
:name => 'Test Daemon',
:path => '/tmp',
:verbose => true
)
# @daemon.send ARGV.first
@daemon.start # stop, status, restart, clean!, and kill.
Install
$ gem install pidly
Copyright
Copyright (c) 2011 Dustin Willis Webber
See LICENSE.txt for details.