Search code examples
ruby-on-rails-3.2unicorn

Rails app gives error only when running via Unicorn


I am in the unfortunate position of having to configure a machine to run multiple Rails applications. Originally the machine was set up with Nginx and rvm and Passenger. It appears to be pretty painful to have to configure multiple standalone Passengers, and it feels like a hack. I just want this application to be up and running, so I'm just going to run it through a different port for now (8080) with Unicorn. Which I hav? no experience with.

My application has a little helper that checks to see if the site is being accessed by a mobile device, then serves up a different set of views. This helper just has a little puts statement in it as a debug line.

When running through Unicorn, the puts line barfs with:

Errno::EIO (Input/output error - <STDOUT>):

All I can think of is that it is unable to write to STDOUT. I have never seen a Rails app bail at a puts line before. Sure it should probably use the logger, but what is the problem with this line in Unicorn when it doesn't have this problem elsewhere.


Solution

  • The EIO error indicates that the process is trying to write to a TTY, but that TTY is now gone. You probably started Unicorn from a terminal, let it daemonize and then you exited the terminal. Setting stderr_path helps because it redirects stderr (and maybe stdout too?) to a file.

    But as for Phusion Passenger: you don't have to setup multiple standalone Passengers anymore. Since Phusion Passenger 4 it supports multiple Rubies.