A blog about Ruby, Rails and other Tech. Mostly.
Back to blog
SCGI rails runner and ECONNRESET problemThere is a hack for running Rails via the SCGI rails runner that is still required, despite this ticket being open for 8 months.
This is the change to cgi_process.rb
# /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.xx.xx/lib/action_controller/cgi_process.rb:
def out(output = $stdout)
convert_content_type!(@headers)
output.binmode if output.respond_to?(:binmode)
output.sync = false if output.respond_to?(:sync=)
begin
output.write(@cgi.header(@headers))
if @cgi.send(:env_table)['REQUEST_METHOD'] == 'HEAD'
return
elsif @body.respond_to?(:call)
@body.call(self, output)
else
output.write(@body)
end
output.flush if output.respond_to?(:flush)
rescue Errno::EPIPE => e
# lost connection to the FCGI process -- ignore the output, then
rescue Errno::ECONNRESET => e
# same as above but for scgi.
end
end
If you don't have this hack in place, Rails will occasionally die with an ECONNRESET, and your website will be toast until you kill and restart the scgi rails runner.
Back to blog |