• Mongrel Gem and Paperclip Plugin Problems

    This problem occurred when setting up a site using mongrel along with the paperclip rails plugin. After about a week of normal operation we started having lots of problems with the automated image resizing required by the rails application.

    It was running along and generating all the images just fine, then all of a sudden it stopped processing the ‘large’ images or made them blurry, and we started seeing the following in the application logs:

    Paperclip::NotIdentifiedByImageMagickError: /folder/stream.####.# is not recognized by the 'indentify' command.

    This is a very strange problem since the development environments work just fine and the developers were insistent that the server was the problem and not the code, as they usually do.

    After dissecting the development environment, we discovered that the problem was with how the application was passing commands to the local computers ImageMagick install from the paperclip plugin when served by mongrel.   The developers all work in Netbeans which, when debugging, serves the application up on Webrick. Everything worked exactly as it should in this environment, so maybe it was the server after all.

    In order to test our hypothesis, we served up the application on the development machine using mongrel instead of Webrick. Not surprisingly, the error returned and it would no longer generate the appropriate thumbnails and larger images on the developers machine. What a pain in the ass, since we serve most of our rails applications using a mongrel cluster, this is a bit of a problem.

    Fortunately, there are many alternatives to mongrel (Webrick being one). However, we do not care for the performance of Webrick as a production web server, as we have always liked using either nginx or apache in conjunction with mongrel or a mongrel cluster. That left us with mod_rails (AKA: Phusion Passenger). Phusion Passenger is a very simple mod that can be enabled on Apache in order to allow the serving of rails applications. It is really quite useful and saves the headaches of all the mongrel process management, as there are no mongrel processes.

    Once we setup mod_rails, all of the image resizing and saving issues went away. We found that the paperclip gem was passing image sizes that were not being honored by mongrel at all, and not saving the image properly, thus getting blurred.

    Now if someone could pinpoint if it was a problem with mongrel and paperclip, or with the code itself, that would be most useful. The fact that it worked just dandy with Webrick, and now apache with mod_rails makes me wonder if there is perhaps an issue with how mongrel is receiving the variables from the paperclip rails plugin.


    Leave a reply