开发者

Why does Rails with Passenger/nginx only works in development mode? No logs available

I have a serious problem with one of our webservers... after having an internal alpha-testing with a mongrel/haproxy-cluster that worked well, we wanted to use nginx with passenger for our first production server (customers will access this server).

However, I can only run the rails app via development mode with passenger/nginx.

The app itself runs perfect with mongrel or webrick in production mode.

My biggest problem with this case is that I don't find ANY information in the nginx or rails-logs (only when I use mongrel or webrick).

Permissions are correct. Passenger-status shows that the app is running, but I always get the static 500.html-error page...

It would be so nice if you guys could give me a hint and help me solve the problem.

I put the config at the bottom of the post... This exact config works with rails_env development;but I'd like to use the production mode ;-)

Thank you very much for your help!


Version: Ubuntu 8.04.2 64bit / nginx-0.7.64 (compiled and installed via passenger-2.2.11)

cat /opt/nginx/conf/nginx.conf

user  www-data;
worker_processes  4;

error_log  logs/error.log;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
      passenger_root /usr/开发者_运维百科lib/ruby/gems/1.8/gems/passenger-2.2.11;
      passenger_ruby /usr/bin/ruby1.8;


    passenger_log_level 3;
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  logs/access.log;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  <<servername>>;


 root /srv/app01/public;
 passenger_enabled on;
}


Passenger with Nginx runs in production mode by default. Use the passenger-install-nginx-module command to install nginx compiled with the Passenger module. Are you sure that you've created and migrated the database for production mode?

rake db:create RAILS_ENV=production
rake db:migrate RAILS_ENV=production

Your nginx.conf looks right to me. Make sure that the nginx user (E.g www-data) has access to your rails app.

Good luck


just remove config.ru from your app directory

passenger will switch from rack to rails and everything will work


I run Rails 2.3.5 on Passenger behind nginx, and I've had the very same problem. My solution is always to switch over to development mode in Passenger/nginx or production mode in WEBrick to debug, but it sounds like you've tried both.

Did you try uncommenting the line error_log logs/error.log; in your nginx.conf?


It's a bug in Rails. The failsafe middleware doesn't properly flush the error message to the log files. I reported and fixed this issue a few months ago but they haven't released it yet: https://rails.lighthouseapp.com/projects/8994/tickets/3577-failsafe-middleware-should-flush-the-logger Apply the patch yourself and you should be able to see the error message in the logs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜