>From that first link I provided:  "... dizave: Are you guys seeing
performance problems with the fact that rails controllers are
essentially forced to single-threaded under mongrels? ...  Zed A.
Shaw: dizave, just wanted to clarify that Rails is always single
threaded, even under FastCGI, SCGI, and WEBrick. Under Mongrel it’s
just exposed to you and isn’t a dirty little secret. ..."

Trust me, your wget call is being blocked, because it's wating for the
orig request to generate_archive to finish (which itself is waiting
for your wget call to finish, which it won't until it times-out) so
that it can be handled by your single instance mongrel/rails setup.
This is why you need another instance of your rails app running to get
around this blocking problem.  So either fire up a second mongrel dev
env instance on a diff port and use that for your internal wget calls,
or setup your dev env to be served via passenger, or ....

As for the problems you're having with your archiving process, ....
If it were me, I'd pull out that code into a separate class, that is
callable via a class method into which you pass the necessary params
to complete the archiving process, something like:

  class Archiver

    def Archiver.gen_archive(....)
      ....
    end
  end

This way you can easily test your archiving process via unit tests,
console, and/or runner ($ ./script/runner 'puts Archiver.gen_archive
(...)' ), to ensure that it works properly.  Once you know it's
working correctly, then you can mod your controller code accordingly.

Jeff

On Apr 24, 5:48 pm, Carlos Santana <[email protected]>
wrote:
> I am really confused now.
> The FAQ says - Mongrel uses one thread per request.
> So it can handle multiple requests (not surprising).
>
> What you are suggesting is that my archiving method is trying to make
> another http req. call within same  http request?
>
> I can see the wget requests in the mongrel (development.log). Clearly,
> its not blocking these requests.
>
> However, it is blocking other http requests (if I try to access my
> application from a browser, then it times out or waits forever).
> So it is not processing other requests. This could be because server has
> reached max. number of connections.. (just one possibility).
>
> I tried Passenger and it is really cool. However, there seems to be some
> serious problem with my archiving code. When I run my app. using
> passenger and try archiving method then, system slows down and I had to
> reboot it forcefully.
> The wget seems to make infinite calls to the server.
>
> I am posting my archiving code for ref.:
> ----------------
>   def generate_archive
>     dir = "/tmp/topicsys/#{self.id}"
>     title = self.title.gsub(/^\s+/, '').gsub(/\s+$/, '').gsub(/\s+/,
> '-')
>     id = self.id
>     host = "#{RAILS_ENV}_HOST".upcase.constantize
>     url = url_for :host => host, :controller => :topics, :action =>
> :show, :id => id
>     logger.info "Generating topic - (#{title}) archive '#{dir}'."
>     pid = fork do
>      `wget --page-requisites --html-extension --convert-links
> --no-directories --recursive --level=1 -np --directory-
> prefix=#{dir} #{url};`
>      #`mv #{dir}/#{id}.html #{dir}/index.html;`
>       `zip -mj #{dir}/#{title}.zip #{dir}/*;`
>     end
>     Process.detach(pid)
>   end
>
> ----------------
>
> Any clues?
>
> Jeff Burlysystems wrote:
> > If you have a single instance of mongrel running your rails app, then
> > it is essentially "single threaded" when it comes to handling requests
> > (see comments in
> >http://weblog.rubyonrails.org/2006/5/18/interview-with-mongrel-develo...
> > orhttp://mongrel.rubyforge.org/wiki/FAQor ....).
>
> > Another alternative would be to setup your dev env to run via
> > mod_rails/passenger, something like
> >http://accidentaltechnologist.com/ruby/replicating-rails-project-setu...
> > and the single-threaded-blocking issue goes away.
>
> > Jeff
>
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to