Ruby-on-rails 来自 Nginx / 乘客的“从应用程序收到的不完整响应”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29241053/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 00:09:38  来源:igfitidea点击:

"Incomplete response received from application" from nginx / passenger

ruby-on-railsnginxpassenger

提问by juicy

I tried to deploy my rails app on nginx and ubuntu via capistrano like the tutorial on the page https://gorails.com/deploy/ubuntu/14.04. but at the end i get an error message:

我尝试通过 capistrano 在 nginx 和 ubuntu 上部署我的 rails 应用程序,就像页面https://gorails.com/deploy/ubuntu/14.04上的教程一样。但最后我收到一条错误消息:

Incomplete response received from application

in my browser. this is probably an error from passenger, but how can i figure out what to do?

在我的浏览器中。这可能是乘客的错误,但我怎么知道该怎么做?

回答by Yaniv Vova Alterman

Your rails_env production don't have required set up,probably missing secret_key_base.

您的 rails_env 产品不需要设置,可能缺少 secret_key_base。

Open /etc/nginx/sites-available/defaultand change the rails_env to development:

打开/etc/nginx/sites-available/default并将 rails_env 更改为 development:

rails_env production;
        to
rails_env development;

If the app is loading it's not a passenger issue.

Production Solution:

如果应用程序正在加载,则不是乘客问题。

生产解决方案:

  1. Enter your app root
  2. run: rake secret
  3. copy the output
  4. go to /yourapp/config/secrets.yml
  5. set the production secret_key_base
  1. 输入您的应用根目录
  2. 跑: rake secret
  3. 复制输出
  4. /yourapp/config/secrets.yml
  5. 设置生产 secret_key_base

Restart the passenger app :

重新启动乘客应用程序:

touch /yourapp/tmp/restart.txt

回答by Hoa Hoang

This error occurs because you didn't set the secret_key_base. Follow these steps to fix it:

发生此错误是因为您没有设置 secret_key_base。请按照以下步骤修复它:

Go to your rails app directory

转到您的 rails 应用程序目录

cd /path/rails-app

Generate secret key base

生成密钥库

rake secret RAILS_ENV=production

Set environment variable

设置环境变量

SECRET_KEY_BASE=<the-secret-key-base>

Restart the Rails app

重启 Rails 应用

touch /path/rails-app/tmp/restart.txt

回答by Ctpelnar1988

For those using Passenger:

对于那些使用乘客:

? Navigate to root of your project.

? 导航到项目的根目录。

? run bundle exec rake secret RAILS_ENV=production

? 跑bundle exec rake secret RAILS_ENV=production

? Copy the output and then run sudo nano config/secrets.yml

? 复制输出然后运行sudo nano config/secrets.yml

? Under production, replace the value of the secret_key_basewith the recently copied rake secret.

? 在 下production,用secret_key_base最近复制的 rake secret替换 的值。

? press CNTRL+X, then press y, then hit enter.

? 按CNTRL+X,然后按y,然后打enter

? run passenger-config restart-appand select the app you wish to restart.

? 运行passenger-config restart-app并选择要重新启动的应用程序。

https://www.phusionpassenger.com/library/admin/apache/restart_app.html

https://www.phusionpassenger.com/library/admin/apache/restart_app.html

回答by user208769

I had this problem over the weekend (it turned out there was an incompatibility between my versions of passenger and ruby).

我在周末遇到了这个问题(结果是我的乘客版本和 ruby​​ 版本不兼容)。

However, nobody seems to be mentioning: the actual error might appear in /var/log/apache2/errors.log, not in any custom log.

但是,似乎没有人提到:实际错误可能出现在 /var/log/apache2/errors.log 中,而不是任何自定义日志中。

Once you know that, hopefully your search will be easier!

一旦你知道了,希望你的搜索会更容易!



Update, since I needed to refer back to this again - this hold true for nginx too - /var/log/nginx/error.logis your friend in that case!

更新,因为我需要再次参考这个 - 这也适用于 nginx -/var/log/nginx/error.log在这种情况下是你的朋友!

回答by mridula

In my case, it was because my server was running out of RAM intermittently (during PDF generation). Once the PDF was generated, some RAM was restored and the error would disappear.

就我而言,这是因为我的服务器间歇性地耗尽 RAM(在 PDF 生成期间)。生成 PDF 后,会恢复一些 RAM,错误就会消失。

I had an ubuntu server with 500M of RAM.

我有一个带有 500M RAM 的 ubuntu 服务器。

I added some swap spaceand this error disappeared.

添加了一些交换空间,这个错误消失了。

回答by jeremywoertink

This means that your rails app tanked before actually getting to rails itself. This could be an exception in middleware, missing ENV key, something at the OS level.

这意味着您的 rails 应用程序在真正进入 rails 本身之前就崩溃了。这可能是中间件中的一个例外,缺少 ENV 密钥,这是操作系统级别的。

Try booting the app locally first and doing what you did to get the error in production. If everything is fine, check all of your logs. Check nginx logs, your passenger logs, and finally any other OS specific logs pertaining to booting and running your app.

尝试首先在本地启动应用程序并执行您所做的操作以在生产中获得错误。如果一切正常,请检查所有日志。检查 nginx 日志、乘客日志,最后检查与启动和运行应用程序有关的任何其他操作系统特定日志。

回答by fanjieqi

Is there anybody like me who got this error after uploading a file?

有没有像我一样上传文件后出现这个错误的人?

My solution is check the name of the file which may has some special characters like `[(~.

我的解决方案是检查文件的名称,该名称可能包含一些特殊字符,例如`[(~.

Just remove it then upload the file again.

只需删除它,然后再次上传文件。

Good luck~

祝你好运~

回答by Andrew Koster

I got this, only on my test server and not in production, because I was requesting a URL that didn't exist, and I guess in the test environment, Rails throws an error instead of returning a 404 response.

我得到了这个,只在我的测试服务器上而不是在生产中,因为我请求的 URL 不存在,我猜在测试环境中,Rails 抛出错误而不是返回 404 响应。

回答by William Hu

Might be my answer is off topic, but when my database mysqlserver isn't running, i got this error too. Just in case someone has the same error.

可能是我的回答跑题了,但是当我的数据库mysql服务器没有运行时,我也收到了这个错误。以防万一有人有同样的错误。

so start/restartyour database might be another answer.

所以start/restart你的数据库可能是另一个答案。