I am trying to run a ruby script in rails application using system call, like
def runSystemCall
system("ruby /path/to/ruby/script/watir.rb localhost:3000/articles/14")
end
and watir.rb
:
def watir(url)
bb = Watir::Browser.new :chrome
bb.goto "#{url[0]}"
end
watir(ARGV)
when running this in rails application, a browser opened and stay in a status of Waiting for localhost...
, until error
.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/protocol.rb:158:in `rescue in rbuf_fill': Net::ReadTimeout (Net::ReadTimeout)
loaded the website localhost:3000/articles/14
opened.
Dose anyone know why?
and, when run this in a terminal
$ ruby /path/to/ruby/script/watir.rb localhost:3000/articles/14
a browser opened and open website localhost:3000/articles/14
That's what I expected.
Your local server is single threaded. That means it can only handle one request at a time. If one local request wants to load an other page from the same local server, than you need at least two local threads.