Not sure if this is a bug or something that just needs configuration tweaks to work correctly, I'll do my best to explain:
Im running into a Broken Pipe issue with the following code running on 2.2.5. The same thing under Mongrel works fine, so I assume there is something I can do to get this to work under LS, but just dont know what that would be. The broken pipe error happens extremely quick, so i believe the case of the external process taking too long is ruled out.
Summary: The run method executes an external process (htmldoc), feeds it some text, then should close the write process and send the PDF back.
My guess: I'll take a stab and say I think it works in Mongrel because mongrel is one ongoing process that obtains the ability to fork/lock/etc once and has that ability thereafter, where as LS works differently?
It wont work for any external process as far as I can tell (whatever popen does, doesnt work in a LSAPI instance maybe?), but since I have this code already, Im using htmldoc as the example.
Here is the code and the error:
Im running into a Broken Pipe issue with the following code running on 2.2.5. The same thing under Mongrel works fine, so I assume there is something I can do to get this to work under LS, but just dont know what that would be. The broken pipe error happens extremely quick, so i believe the case of the external process taking too long is ruled out.
Summary: The run method executes an external process (htmldoc), feeds it some text, then should close the write process and send the PDF back.
My guess: I'll take a stab and say I think it works in Mongrel because mongrel is one ongoing process that obtains the ability to fork/lock/etc once and has that ability thereafter, where as LS works differently?
It wont work for any external process as far as I can tell (whatever popen does, doesnt work in a LSAPI instance maybe?), but since I have this code already, Im using htmldoc as the example.
Here is the code and the error:
Code:
class StuffController < ApplicationController
def run
generator = IO.popen('htmldoc -t pdf14 --webpage -', 'w+')
generator.puts render_to_string("stuff/_preview") #LINE 53 in my actual controller
generator.close_write
send_data generator.read, :filename => "preview.pdf", :type => 'application/pdf', :disposition => 'inline'
end
end
Errno::EPIPE (Broken pipe):
/app/controllers/stuff_controller.rb:53:in `write'
/app/controllers/stuff_controller.rb:53:in `run'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in `perform_action_without_filters'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:368:in `perform_action_without_benchmark'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'
/usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/rescue.rb:82:in `perform_action'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in `process_without_filters'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:377:in `process_without_session_management_support'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/session_management.rb:117:in `process'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in `dispatch'
/usr/local/lsws/fcgi-bin/RailsRunner.rb:12