I'm runnning a lot of jobs through capybara on my linux server. I'm using the poltergeist phantomjs driver. After A while I'm getting a lot of these errors:
Errno::EMFILE Too many open files - socket(2)
I looked in lsof
and it looks like I have a LOT of these:
ruby 32316 deployer 320u IPv4 9893211 0t0 TCP localhost:55062 (LISTEN)
Now i'm suspecting that it might be because I'm not getting the connection correctly closed?
What would be the correct way of terminating after running something like the following:
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, {:js_errors => false})
end
Capybara.current_driver = :poltergeist
Capybara.javascript_driver = :poltergeist
Capybara.run_server = false
@session = Capybara::Session.new(:poltergeist)
@session.visit('some_url')