Dealing with Application error (Rails) in production


#1

Hi all,

Week 2 working with Ruby on Rails… I have a working app in development
that is now throwing a generic, “Application error (Rails)” message in
production.

How do I deal with this so I can find more information about why the
error is being thrown in production, but not in development?

Thanks!


#2

Look in the log file, I presume.

Kent.


#3

Dan C. wrote:

Hi all,

Week 2 working with Ruby on Rails… I have a working app in development
that is now throwing a generic, “Application error (Rails)” message in
production.

How do I deal with this so I can find more information about why the
error is being thrown in production, but not in development?

Thanks!

You’re not saying whether you only changed the environment or also the
web server. In the first case try looking in production.log. In the
second case you can also try your webserver’s error log and any relevant
log like the fcgi crash log.

have a look at these pieces of advise, they mention some of the gotchas


Agnieszka


#4

Kent S. wrote:

Look in the log file, I presume.

Kent.

Thanks, Kent. I looked in the production.log file and found this
particular error:

Errno::EPIPE (Broken pipe)

Any idea what that is about?

I started seeing the error when I switched over from Apache to a
lighttpd web server .


#5

Dan C. wrote:

Hi all,

Week 2 working with Ruby on Rails… I have a working app in development
that is now throwing a generic, “Application error (Rails)” message in
production.

How do I deal with this so I can find more information about why the
error is being thrown in production, but not in development?

Thanks!

Have you modified your database and migrated the changes on your
production server?

If you add a database field locally and refer to it in your code, you
can get these errors on your production server if the database schema
isn’t up to date.

Jeff


#6

Agnieszka F. wrote:

You’re not saying whether you only changed the environment or also the
web server. In the first case try looking in production.log. In the
second case you can also try your webserver’s error log and any relevant
log like the fcgi crash log.

have a look at these pieces of advise, they mention some of the gotchas


Agnieszka

Agnieszka,

Thank you for your response. I looked at the sites you provided and it
seemed like that information was relevant to the “Rails application
failed to start properly” error.

I may have been unclear, but my application is running. The home page
is merely a single text field and submit button. When a user enters
their email address and hits “Submit,” their information is recorded
into the database.

The error I am seeing is “Application error (Rails)” when I try to log
into the password-protected administrative section of the web site.


#7

Dan C. wrote:

Kent S. wrote:

Look in the log file, I presume.

Kent.

Thanks, Kent. I looked in the production.log file and found this
particular error:

Errno::EPIPE (Broken pipe)

Any idea what that is about?

I started seeing the error when I switched over from Apache to a
lighttpd web server .

If you look at the unreleased changelog for Lighttpd, it shows that it
fixes a fastcgi problem. The unreleased fixes in Lighttpd also include
connections not getting closed on certain errors, and memory leaks.

Try compiling the Lighttpd version in the repository, or wait until
1.4.12 is released. Or use Apache 2.0.55 with mod_fcgid-1.08 (not
mod_fastcgi!).

You can see the changesets at

http://trac.lighttpd.net/trac/timeline?changeset=on&update=Update


#8

I’m only posting this so the next person who has this error will see
it…
Whenever you see this error, modify your database.yml file so that your
development and production databases are the same and then launch your
app
with WEBrick in Development mode. This will rule out your Rails app as
the
problem so you can then look at the OS / webserver / database.


#9

Jeff C.man wrote:

Have you modified your database and migrated the changes on your
production server?

If you add a database field locally and refer to it in your code, you
can get these errors on your production server if the database schema
isn’t up to date.

Jeff

Hi Jeff,

I created the database table by hand using TextDrive’s (my web hosting
company’s) web-based MySQL admin tool. The only thing that is different
about the table versus the development version as far as I can tell is
the password column. On dev, it is of type char(40), whereas on
production, the web-based tool forces the column to be of type
varchar(40).

Could that be causing the problem?


#10

Brian H. wrote:

I’m only posting this so the next person who has this error will see
it…
Whenever you see this error, modify your database.yml file so that your
development and production databases are the same and then launch your
app
with WEBrick in Development mode. This will rule out your Rails app as
the
problem so you can then look at the OS / webserver / database.

Hi Brian,

Are you saying to change the database information for development in the
database.yml to point to the production database? I’m not sure that my
web hosting company is going to let me connect in that way…

Can’t I just turn the default Rails error messaging to give me full dev
errors somewhere? (temporarily of course while I track down the
problem) Or will my web host not allow me to do that, either?


#11

You could do that as well. Or you could get really clever and have the
errors emailed to you… that way you’ll always get them when you’re in
production so you can respond to them.


#12

Peter G. wrote:

If you look at the unreleased changelog for Lighttpd, it shows that it
fixes a fastcgi problem. The unreleased fixes in Lighttpd also include
connections not getting closed on certain errors, and memory leaks.

Try compiling the Lighttpd version in the repository, or wait until
1.4.12 is released. Or use Apache 2.0.55 with mod_fcgid-1.08 (not
mod_fastcgi!).

You can see the changesets at

http://trac.lighttpd.net/trac/timeline?changeset=on&update=Update

Peter,

Thanks for the response. Fiddling with lighttpd scares the hell out of
me right now and that solution is way over my head. I passed it along
to my web hosting company in case there is something they need to know
there.


#13

Brian H. wrote:

You could do that as well. Or you could get really clever and have the
errors emailed to you… that way you’ll always get them when you’re in
production so you can respond to them.

Brian,

Great minds think alike. When you posted this, I had just gone through
the process of setting up the emailed errors:
http://wiki.rubyonrails.com/rails/pages/HowtoSendEmailWhenRailsThrowsAnException

Unfortunately, as with just about everything else I’ve done with Ruby on
Rails to this point, it doesn’t seem to work yet. I repeated the error
behavior on both development and production and no emails have been
sent.

I’m seriously contemplating going back to ASP.NET if I can’t get a
working app running in Rails soon. Blaah.


#14

Ack! Don’t do that! Don’t give up just yet. There are several good
examples
on the web regarding this.

But you should already have a working, tested app that runs locally…
unit, functional, and integration tests can help you find all sorts of
bugs
before you go to a production mode environment.


#15

Hi Dan,

I think you will find that the exception_notification plugin will help
immensely for you. I wrote up a brief entry on my blog about it:

http://blog.atomgiant.com/articles/2006/03/20/global-error-handling

Feel free to email me directly if you have any problems.

Tom

On 4/5/06, Brian H. removed_email_address@domain.invalid wrote:

Whenever you see this error, modify your database.yml file so that your
web hosting company is going to let me connect in that way…
http://lists.rubyonrails.org/mailman/listinfo/rails


Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails


Tom D.

http://blog.atomgiant.com
http://gifthat.com


#16

Tom D. wrote:

Hi Dan,

I think you will find that the exception_notification plugin will help
immensely for you. I wrote up a brief entry on my blog about it:

http://blog.atomgiant.com/articles/2006/03/20/global-error-handling

Feel free to email me directly if you have any problems.

Tom

Thanks, Tom. That will be a big help for emailing the erros to me. I’m
configuring ActionMailer for the first time now (must have been why I
haven’t been able to get any emails to send thus far).

I think the other problems I’ve been having are “rookie” problems as
well. I think I have dug up information through my own research that I
have to restart the FCGI processes every time I move my Rails code up to
the production server? Is that right and I am using the correct
language? I’m still not sure exactly how I go about doing that
(restarting FCGI, but I’ll keep looking while I await a response).

Thanks again to all for your help… Hopefully you’ll be able to prove
the old axiom wrong and you CAN teach an old ASP.NET dog new Ruby on
Rails tricks… :slight_smile:

Dan


#17

Yes, everytime you move your code to the production server you should
restart your lighttpd. If you haven’t tried already, take a look at
Capistrano (aka - SwitchTower). It makes this pretty painless.

To restart lighttpd, I am using a script like this one:

http://textsnippets.com/posts/show/241

I am also hosted at TextDrive and someone else said that script is
there already for you, but I could not find it, so I created my own
from that snippet.

Good luck,

Tom

On 4/5/06, Dan C. removed_email_address@domain.invalid wrote:

Tom
language? I’m still not sure exactly how I go about doing that


Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails


Tom D.

http://blog.atomgiant.com
http://gifthat.com