Skip to content

Instantly share code, notes, and snippets.

@hakanensari
Last active December 11, 2015 03:38
Show Gist options
  • Save hakanensari/4538939 to your computer and use it in GitHub Desktop.
Save hakanensari/4538939 to your computer and use it in GitHub Desktop.
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