Created
February 23, 2010 04:19
-
-
Save samullen/311849 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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