可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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:
Incomplete response received from application
in my browser.
this is probably an error from passenger, but how can i figure out what to do?
回答1:
Your rails_env production don't have required set up,probably missing secret_key_base.
Open /etc/nginx/sites-available/default
and change the rails_env to development:
rails_env production;
to
rails_env development;
If the app is loading it's not a passenger issue.
Production Solution:
- Enter your app root
- run:
rake secret
- copy the output
- go to
/yourapp/config/secrets.yml
- set the production
secret_key_base
Restart the passenger app :
touch /yourapp/tmp/restart.txt
回答2:
This error occurs because you didn't set the secret_key_base. Follow these steps to fix it:
Go to your rails app directory
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
touch /path/rails-app/tmp/restart.txt
回答3:
For those using Passenger:
• Navigate to root of your project.
• run bundle exec rake secret RAILS_ENV=production
• Copy the output and then run sudo nano config/secrets.yml
• Under production
, replace the value of the secret_key_base
with the recently copied rake secret.
• press CNTRL+X
, then press y
, then hit enter
.
• run passenger-config restart-app
and select the app you wish to restart.
https://www.phusionpassenger.com/library/admin/apache/restart_app.html
回答4:
I had this problem over the weekend (it turned out there was an incompatibility between my versions of passenger and ruby).
However, nobody seems to be mentioning: the actual error might appear in /var/log/apache2/errors.log, not in any custom log.
Once you know that, hopefully your search will be easier!
回答5:
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.
I had an ubuntu server with 500M of RAM.
I added some swap space and this error disappeared.
回答6:
Might be my answer is off topic, but when my database mysql
server isn't running, i got this error too. Just in case someone has the same error.
so start/restart
your database might be another answer.
回答7:
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.
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.