如何正确诊断500错误(铁路,乘客,Nginx,Postgres) [英] How to properly diagnose a 500 error (Rails, Passenger, Nginx, Postgres)

查看:73
本文介绍了如何正确诊断500错误(铁路,乘客,Nginx,Postgres)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在生产中运行我的应用程序时,我很难诊断500个错误.我以前曾经使用过它,但是通过Capastrano重新部署后,我无法继续使用它.

I'm having a real tough time diagnosing a 500 error from my application running in production. I've had it working before, but after re-deploying via Capastrano I am unable to get it going.

以下是事实:

  1. 服务器已使用nginx + passenger进行设置,我正在使用 PostgreSQL.
  2. 静态资产运行正常,因为我可以在浏览器中正常访问它们.
  3. 我可以通过RAILS_ENV=production bundle exec rails console访问rails控制台并执行Active Record操作(例如 从数据库中检索数据).
  4. 在控制台中,我可以运行app.get("/"),它也会返回500错误(首先显示了运行以加载的查询后 模型).
  5. 从未写入production.log文件.我已经为它设置了权限777.我还将日志级别设置为 :debug,没什么可显示的.
  6. nginx日志(乘客也使用该日志)没有显示错误指示,只是通知缓存未命中.
  1. The server is setup with nginx + passenger, and I'm using PostgreSQL.
  2. Static assets are working properly, as in I'm able to access them just fine in a browser.
  3. I can access the rails console via RAILS_ENV=production bundle exec rails console and perform Active Record actions (like retrieving data from the db).
  4. Within console, I can run app.get("/"), which returns a 500 error as well (after first showing the query that was run to load the model).
  5. The production.log file is never written to. I've set permissions 777 on it just for the hell of it. I've also set the log level to :debug with nothing to show for it.
  6. The nginx log (which passenger also uses) shows no indication of errors, it just notifies about cache misses.

因为没有任何使用记录在日志中,所以我不知道该怎么办.我尝试在没有帮助的情况下对整个应用程序目录设置完全权限.多次重新启动服务器,没有任何反应.数据库在那里,Rails可以清楚地与它进行通信.我不确定如何使它在第一时间运行.我只是不知道为什么Rails不会在日志中输出任何内容.

Because nothing of use is being logged, I have no idea what to do here. I've tried setting full permission on the entire app directory with no help. Restarted the server multiple times, nothing. The database is there and rails can clearly communicate with it. I'm not sure what I did to get it to run the first time around. I just don't know why rails isn't outputting anything to the log.

推荐答案

好的,我知道了.该应用程序在开发模式下运行良好,因此我知道某些特定于生产的应用程序正在搞砸它.我进入config/environments/production.rb并更改了这些设置:

Okay, I figured this out. The app ran fine in development mode, so I knew something production-specific was screwing it up. I went into config/environments/production.rb and changes these settings:

# Full error reports are disabled and caching is turned on
config.consider_all_requests_local       = false # changed from true
config.action_controller.perform_caching = true # changed from false

然后重新启动乘客之后,rails向我显示了w/stacktrace错误.原来我忘记了预编译资产管道!

And then after restarting passenger, rails showed me the error w/ stacktrace. Turns out I was forgetting to precompile the asset pipeline!

这篇关于如何正确诊断500错误(铁路,乘客,Nginx,Postgres)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆