Yesterday, our of nothing my server went down…
Rails application failed to start properly
Imediately i started checking my logs and found quickly that something
was wrong with the dispatch.fcgi or its function.
I use FCGI, and it had been working perfectly with Apache 2.0.55, MySQL
5.0, Ruby 1.8.2 and Rails 1.1.2.
What really got me wondering was that I did nothing. One day it worked
perfectly, the next day it didnt… no changes made inbetween…
I have the following setup:
dispatch.fcgi:
#!c:/programfiler/ruby/bin/ruby
You may specify the path to the FastCGI crash log (a log of unhandled
exceptions which forced the FastCGI instance to exit, great for
debugging)
and the number of requests to process before running garbage
collection.
By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
and the GC period is nil (turned off). A reasonable number of
requests
could range from 10-100 depending on the memory footprint of your app.
Example:
# Default log path, normal GC behavior.
RailsFCGIHandler.process!
# Default log path, 50 requests between GC.
RailsFCGIHandler.process! nil, 50
# Custom log path, normal GC behavior.
RailsFCGIHandler.process! ‘/var/log/myapp_fcgi_crash.log’
require File.dirname(FILE) + “/…/config/environment”
require ‘fcgi_handler’
RailsFCGIHandler.process!
Yes, the reference to the ruby/bin directory is correct.
.htaccess:
General Apache options
AddHandler fastcgi-script .fcgi
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI
If you don’t want Rails to look in certain directories,
use the following rewrite rules so that Apache won’t rewrite certain
requests
Example:
RewriteCond %{REQUEST_URI} ^/notrails.*
RewriteRule .* - [L]
Redirect all requests not available on the filesystem to Rails
By default the cgi dispatcher is used which is very slow
For better performance replace the dispatcher with the fastcgi one
Example:
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
RewriteEngine On
If your Rails application is accessed via an Alias directive,
then you MUST also set the RewriteBase in this htaccess file.
Example:
Alias /myrailsapp /path/to/myrailsapp/public
RewriteBase /myrailsapp
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
In case Rails experiences terminal errors
Instead of displaying this message you can supply a file here which
will be rendered instead
Example:
ErrorDocument 500 /500.html
ErrorDocument 500 “
Application error
Rails application failed tostart properly”
the errorlog in apache:
[Thu Jun 15 10:32:06 2006] [notice] Apache/2.0.55 (Win32)
mod_fastcgi/2.4.2 DAV/2 SVN/1.3.1 configured – resuming normal
operations
[Thu Jun 15 10:32:06 2006] [notice] Server built: Oct 9 2005 19:16:56
[Thu Jun 15 10:32:06 2006] [notice] Parent: Created child process 5588
[Thu Jun 15 10:32:06 2006] [notice] Child 5588: Child process is running
[Thu Jun 15 10:32:06 2006] [notice] FastCGI: process manager initialized
[Thu Jun 15 10:32:07 2006] [notice] Child 5588: Acquired the start
mutex.
[Thu Jun 15 10:32:07 2006] [notice] Child 1880: Released the start mutex
[Thu Jun 15 10:32:07 2006] [notice] Child 5588: Starting 250 worker
threads.
[Thu Jun 15 10:32:08 2006] [notice] Child 1880: Waiting for 250 worker
threads to exit.
[Thu Jun 15 10:32:08 2006] [notice] Child 1880: All worker threads have
exited.
[Thu Jun 15 10:32:09 2006] [notice] Child 1880: Child process is exiting
[Thu Jun 15 10:32:11 2006] [warn] FastCGI: (dynamic) server
“C:/Website/pagina/public/dispatch.fcgi” started (pid 3152)
[Thu Jun 15 10:32:11 2006] [warn] FastCGI: (dynamic) server
“C:/Website/pagina/public/dispatch.fcgi” (pid 3152) terminated with exit
with status ‘1’
[Thu Jun 15 10:32:16 2006] [warn] FastCGI: (dynamic) server
“C:/Website/pagina/public/dispatch.fcgi” restarted (pid 2100)
[Thu Jun 15 10:32:16 2006] [error] [client 84.48.33.250] (OS
109)Datakanalen er avsluttet. : FastCGI: comm with server
“C:/Website/pagina/public/dispatch.fcgi” aborted: GetOverlappedResult()
failed
[Thu Jun 15 10:32:16 2006] [warn] FastCGI: (dynamic) server
“C:/Website/pagina/public/dispatch.fcgi” (pid 2100) terminated with exit
with status ‘1’
[Thu Jun 15 10:32:16 2006] [error] [client 84.48.33.250] FastCGI:
incomplete headers (0 bytes) received from server
“C:/Website/pagina/public/dispatch.fcgi”
[Thu Jun 15 10:32:21 2006] [warn] FastCGI: (dynamic) server
“C:/Website/pagina/public/dispatch.fcgi” restarted (pid 2476)
[Thu Jun 15 10:32:21 2006] [warn] FastCGI: (dynamic) server
“C:/Website/pagina/public/dispatch.fcgi” (pid 2476) terminated with exit
with status ‘1’
[Thu Jun 15 10:32:26 2006] [warn] FastCGI: (dynamic) server
“C:/Website/pagina/public/dispatch.fcgi” restarted (pid 4592)
[Thu Jun 15 10:32:26 2006] [warn] FastCGI: (dynamic) server
“C:/Website/pagina/public/dispatch.fcgi” (pid 4592) terminated with exit
with status ‘1’
[Thu Jun 15 10:32:26 2006] [warn] FastCGI: (dynamic) server
“C:/Website/pagina/public/dispatch.fcgi” has failed to remain running
for 30 seconds given 3 attempts, its restart interval has been backed
off to 600 seconds
[Thu Jun 15 10:32:27 2006] [warn] FastCGI: (dynamic) server
“C:/Website/pagina/public/dispatch.fcgi” has failed to remain running
for 30 seconds given 3 attempts, its restart interval has been backed
off to 600 seconds
[Thu Jun 15 10:32:28 2006] [warn] FastCGI: (dynamic) server
“C:/Website/pagina/public/dispatch.fcgi” has failed to remain running
for 30 seconds given 3 attempts, its restart interval has been backed
off to 600 seconds
[Thu Jun 15 10:32:29 2006] [warn] FastCGI: (dynamic) server
“C:/Website/pagina/public/dispatch.fcgi” has failed to remain running
for 30 seconds given 3 attempts, its restart interval has been backed
off to 600 seconds
[Thu Jun 15 10:32:30 2006] [warn] FastCGI: (dynamic) server
“C:/Website/pagina/public/dispatch.fcgi” has failed to remain running
for 30 seconds given 3 attempts, its restart interval has been backed
off to 600 seconds
[Thu Jun 15 10:32:31 2006] [warn] FastCGI: (dynamic) server
“C:/Website/pagina/public/dispatch.fcgi” has failed to remain running
for 30 seconds given 3 attempts, its restart interval has been backed
off to 600 seconds
[Thu Jun 15 10:32:32 2006] [warn] FastCGI: (dynamic) server
“C:/Website/pagina/public/dispatch.fcgi” has failed to remain running
for 30 seconds given 3 attempts, its restart interval has been backed
off to 600 seconds
[Thu Jun 15 10:32:33 2006] [warn] FastCGI: (dynamic) server
“C:/Website/pagina/public/dispatch.fcgi” has failed to remain running
for 30 seconds given 3 attempts, its restart interval has been backed
off to 600 seconds
[Thu Jun 15 10:32:34 2006] [warn] FastCGI: (dynamic) server
“C:/Website/pagina/public/dispatch.fcgi” has failed to remain running
for 30 seconds given 3 attempts, its restart interval has been backed
off to 600 seconds
[Thu Jun 15 10:32:35 2006] [warn] FastCGI: (dynamic) server
“C:/Website/pagina/public/dispatch.fcgi” has failed to remain running
for 30 seconds given 3 attempts, its restart interval has been backed
off to 600 seconds
[Thu Jun 15 10:32:36 2006] [warn] FastCGI: (dynamic) server
“C:/Website/pagina/public/dispatch.fcgi” has failed to remain running
for 30 seconds given 3 attempts, its restart interval has been backed
off to 600 seconds
[Thu Jun 15 10:32:37 2006] [warn] FastCGI: (dynamic) server
“C:/Website/pagina/public/dispatch.fcgi” has failed to remain running
for 30 seconds given 3 attempts, its restart interval has been backed
off to 600 seconds
http.conf important parts of it:
<VirtualHost *:80>
ServerName lagraciadedios.org
DocumentRoot “C:/Website/pagina/public”
<Directory “C:/Website/pagina/public”>
Options ExecCGI FollowSymLinks
AllowOverride all
Allow from all
Order allow,deny
AddHandler cgi-script .cgi
AddHandler fastcgi-script .fcgi
fastcgi-crashlog:
[14/Jun/2006:09:22:00 :: 5452] Ignoring unsupported signal USR1.
[14/Jun/2006:09:22:00 :: 5452] Ignoring unsupported signal USR2.
[14/Jun/2006:09:22:00 :: 5452] Ignoring unsupported signal HUP.
[14/Jun/2006:09:22:00 :: 5452] Ignoring unsupported signal SIGTRAP.
[14/Jun/2006:09:22:00 :: 5452] starting
[14/Jun/2006:09:54:11 :: 3500] Ignoring unsupported signal USR1.
[14/Jun/2006:09:54:11 :: 3500] Ignoring unsupported signal USR2.
[14/Jun/2006:09:54:11 :: 3500] Ignoring unsupported signal HUP.
[14/Jun/2006:09:54:11 :: 3500] Ignoring unsupported signal SIGTRAP.
[14/Jun/2006:09:54:11 :: 3500] starting
what I notice is that this crashlog stopped being updated at this
time… after that the fcgi server never started again…
when I try to run dispatch.fcgi by hand through ruby i get:
c:/programfiler/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in
re quire__': ./../config/environment.rb:63: syntax error (SyntaxError) from c:/programfiler/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require .rb:18:in
require’
from dispatch.fcgi:21
could someone help me?
I restarted the apache server several times, reinstalled it, reinstalled
ruby, rails, mod_fcgi.c,mod_ruby… what is the error?