Skip to content

Instantly share code, notes, and snippets.

@diclophis
Created October 14, 2008 20:42
Show Gist options
  • Save diclophis/16785 to your computer and use it in GitHub Desktop.
Save diclophis/16785 to your computer and use it in GitHub Desktop.
def self.daemon
IO.popen("python /root/isk-daemon-0.6.2/isk-daemon.py 2>&1") { |io|
i = ""
thread = Thread.new {
while IO.select([io], nil, nil) do
i = io.gets
puts i
break if i.nil?
end
}
sleep 0.1 until i.include?("init finished")
begin
yield
rescue => problem
raise problem
ensure
self.shutdown
thread.join
end
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment