Created
February 2, 2012 20:07
-
-
Save netshade/1725469 to your computer and use it in GitHub Desktop.
Agent fork test
This file contains hidden or 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 'logger' | |
require 'instrumental_agent' | |
Instrumental::Agent.logger = Logger.new(STDOUT) | |
a = Instrumental::Agent.new('YOUR_API_KEY') | |
t = Time.now.to_i | |
forked = nil | |
a.increment("fork.start") | |
sleep(5) | |
main = fork do # Phusion fork | |
loop do | |
a.increment("main.loop") | |
if !forked && (Time.now.to_i - t) > 10 | |
child = fork do # App fork | |
loop do | |
a.increment("forked.loop") | |
puts "FORK SEND!" | |
sleep 1 | |
end | |
end | |
Process.detach(child) | |
forked = true | |
end | |
puts "MAIN SEND" | |
sleep 1 | |
end | |
end | |
Process.wait(main) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment