I often get a "premature end of script headers" error in my apache log which results to an internal 500 error. I understand what the error message means - that my application did not give the browser the headers it needs (and maybe nothing at all), but the odd thing is that this does not happen all the time. It actually usually happens the first few times I go to my website after a deploy. Could this be a memory issue? Does anyone know how to trouble shoot this? My apache log isn't really telling me anything.
I am running a ruby site using the rails framework on ubuntu hardy.
thank you!
If this is happening right after a deploy, what it probably means is that the Ruby process is restarting and isn't ready to serve pages yet. Apache will only give it a certain amount of time to serve each page, and then it will time it out and serve a 500. Once the Ruby process 'warms up' then everything is fine again.
Your Apache access logs should tell you how long the failed requests took. My guess is that they will be the same as an Apache-configured timeout; for example: http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html#fcgidconnecttimeout
What script are you running, Perl?
You can try enabling warnings and using Carp to trap the errors like this: