Rails 应用程序随机崩溃并出现错误“脚本标题过早结束"; [英] Rails app randomly crashes with error "Premature end of script headers"

查看:58
本文介绍了Rails 应用程序随机崩溃并出现错误“脚本标题过早结束";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 DreamHost 上托管了一个 Ruby on Rails 2.0.2 应用程序.它位于 Apache 2 服务器上,运行在 Phusion Passenger 之上.

I am hosting a Ruby on Rails 2.0.2 application on DreamHost. It is on an Apache 2 server, running on top of Phusion Passenger.

应用程序经常返回 500 错误Rails 应用程序无法正常启动",但随机出现.当应用程序处于较高负载时似乎会发生这种情况,但我无法确认这一点.它每天只能获得大约 2,000 次综合浏览量,所以我认为负载应该不是问题.

The application often returns a 500 error "Rails application failed to start properly", but at random times. It appears to happen when the application is under higher load, though I can't confirm this. It only gets about 2,000 pageviews per day, so I don't think load should really be an issue.

Apache 日志将这 500 个响应与错误相关联:脚本标头过早结束".今天早上 9 点查看日志,该错误每分钟出现三四次.这显然是不可接受的.

The Apache logs correlate these 500 responses with the error: "Premature end of script headers". Just looking at the logs at 9 AM today, the error appears as often as three or four times a minute. This is clearly unacceptable.

应用程序偶尔会抛出一个带有堆栈跟踪和错误Broken pipe"的 Phusion Passenger 页面.

Less frequently, the application hurls a Phusion Passenger page with a stack trace and the error "Broken pipe".

Rails 日志没有列出任何这些错误.

The Rails logs do not list any of these errors.

这发生在 DreamHost 上托管的临时站点和实时站点上,但我无法在本地开发服务器上复制它.

This happens on both the staging and live sites hosted on DreamHost, but I can't replicate it on a local development server.

所以我想真正的问题是:我从哪里开始调试这个问题?

So I guess the real question is: Where do I begin to debug this problem?

推荐答案

事实证明,我只是在 DreamHost 共享服务器上达到了我的内存上限.

It turns out that I was merely hitting my memory cap on the DreamHost shared server.

我在一个帐户下运行了多个 Rails 应用程序,其中许多仅用于测试和原型设计.Rails 使用了大量内存,所以我很快就达到了我的分配.支持人员告诉我我检查了我们的日志,它在过去三天中杀死了您的一个 ruby​​ 进程 2325 次".糟糕.

I was running several Rails apps under one account, many of them just for testing and prototyping. Rails uses a lot of memory and so I was quickly reaching my allocation. Support told me that "I checked our logs and it's killed one of your ruby processes 2325 times over the last three days". Whoops.

解决办法:尽量不要在共享环境中运行Rails,如果可以的话.我打算尽快将我的至少一个应用程序切换到 VPS 主机.

The solution: try not to run Rails in a shared environment, if you can help it. I'm going to switch at least one of my apps to a VPS host soon.

这篇关于Rails 应用程序随机崩溃并出现错误“脚本标题过早结束";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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