Last active
December 11, 2015 03:38
-
-
Save hakanensari/4538939 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
require 'capybara/dsl' | |
require 'capybara-webkit' | |
require 'headless' | |
Capybara.default_driver = :webkit | |
Capybara.run_server = false | |
class Page | |
include Capybara::DSL | |
def initialize(url) | |
visit url | |
end | |
end | |
pids = 10.times.map do | |
fork do | |
Headless.run do | |
loop do | |
page = Page.new 'http://hakanensari.com' | |
File.open("/tmp/f#{Process.pid}", 'a') do |f| | |
f.write "#{Time.now.to_i}\n" | |
end | |
end | |
end | |
end | |
end | |
Kernel.trap( "INT" ) do | |
STDOUT.puts 'Exiting...' | |
pids.each { |pid| Process.kill 'HUP', pid } | |
Process.abort | |
end | |
sleep 1000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment