Rmagick dead on resize process

apps

#1

Hi, this is my first post :).

Problem: I can’t resize any image with Rmagick in rails application.

I soppose:
1 - Rmagick eats a lot of memory
and 2 - FCGI (or DH policies) kill the process to protect the others users of the shared server.

I do:

  • make an RoR application to upload images. A simple model with post and many images.
  • create a new domain user and assign this application.
  • freeze gems
  • change .htaccess[1] and fcgi distpacher[2]
  • deploy an aplication with svn and capistrano.

My Report:

  • The application works fine, fast, except the image uploading, it crash!

Solutions:

  • Drop out Rmagick and install other gem for image manipulation. ImageScience for example. But Rmagick is the most complete tool.
  • Extend my account to http://www.dreamhostps.com/ with >200MB of RAM.
  • Find other job where they do not have technology involved such as goats keeper :slight_smile: [joke]

Question:
Someone could successfully implement an application to upload images?

Thanks in advance!!,
Dario

Source:

[1]
AddHandler fastcgi-script .fcgi
Options +FollowSymLinks +ExecCGI
RewriteEngine On
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

[2] -> from http://gabrito.com/post/ruby-on-rails-dreamhost-plugin
NOTE: If not added this script or similar, most of the applications don’t work or run veeeeery slow.

#!/usr/bin/ruby1.8

require File.dirname(FILE) + “/…/config/environment“
require ‘fcgi_handler‘

class RailsFCGIHandler
private
def busy_exit_handler(signal)
dispatcher_log :info, “busy: asked to terminate during request signal #{signal}, deferring!“
@when_ready = :exit
end

Dreamhost sends the term signal and if we’re handling a request defer it

def term_process_request(cgi)
install_signal_handler(’TERM‘,method(:busy_exit_handler).to_proc)
Dispatcher.dispatch(cgi)
rescue Exception => e # errors from CGI dispatch
raise if SignalException === e
dispatcher_error(e)
ensure
install_signal_handler(’TERM‘, method(:exit_now_handler).to_proc)
end
alias_method :process_request, :term_process_request
end

RailsFCGIHandler.process!

Dario E. Brozzi


#2

The problem is in File_column, in Gravity variable for crop functionality.

Solution:
“Open up /vendor/plugins/file_column/lib/magick_file_column.rb, and remove the ‘true’ parameter to the img.crop function call on line 90”

Extracted from original solution by bentlegen’s comment[1]

[1]File_column Plugin Broken : http://wiki.dreamhost.com/Talk:Ruby_on_Rails

Dario E. Brozzi