Skip to content

Instantly share code, notes, and snippets.

@samullen
Created February 23, 2010 04:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samullen/311849 to your computer and use it in GitHub Desktop.
Save samullen/311849 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'basic_daemon'
class MyDaemon < BasicDaemon
def run
foo = open("/tmp/out", "w")
i = 1
while true do
foo.puts "loop: #{i}"
foo.flush
sleep 2
i += 1
end
end
end
d = MyDaemon.new
if ARGV[0] == 'start'
d.start
elsif ARGV[0] == 'stop'
d.stop
exit!
elsif ARGV[0] == 'restart'
d.restart
else
STDERR.puts "wrong! use start, stop, or restart."
exit!
end
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment