Rmagick dead on resize process
Posted by: dario brozzi
Posted on: 2007-10-22 17:48:00
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 :) [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