Error in dispatch.fcgi

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 to
start 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:inrequire’
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?

See my article on Apache + FCGI for Windows. You want to use static
servers,
not dynamic servers.

http://www.napcs.com/howto/rails/deploy/

Hopefully something there can help you.

Brian H. wrote:

See my article on Apache + FCGI for Windows. You want to use static
servers,
not dynamic servers.

http://www.napcs.com/howto/rails/deploy/

Hopefully something there can help you.

thanks for the help… but it didnt fix my problem… no matter what I
do, i end up with the same problem.

i have reinstalled the whole thing over again, and even made a new rails
project.
It worked fine until i started pasting the original files i have been
working with…
my next step is to paste file by file and check for errors. I’ll come
back with my findings later.

Hernan Lopez wrote:

Brian H. wrote:

See my article on Apache + FCGI for Windows. You want to use static
servers,
not dynamic servers.

http://www.napcs.com/howto/rails/deploy/

Hopefully something there can help you.

thanks for the help… but it didnt fix my problem… no matter what I
do, i end up with the same problem.

i have reinstalled the whole thing over again, and even made a new rails
project.
It worked fine until i started pasting the original files i have been
working with…
my next step is to paste file by file and check for errors. I’ll come
back with my findings later.

by the way I forgot to comment. My errorlog now shows this using static
server:
[Thu Jun 15 17:29:35 2006] [notice] Parent: Received restart signal –
Restarting the server.
[Thu Jun 15 17:29:35 2006] [notice] Child 2948: Exit event signaled.
Child process is ending.
[Thu Jun 15 17:29:35 2006] [notice] Apache/2.0.55 (Win32)
mod_fastcgi/2.4.2 configured – resuming normal operations
[Thu Jun 15 17:29:35 2006] [notice] Server built: Oct 9 2005 19:16:56
[Thu Jun 15 17:29:35 2006] [notice] Parent: Created child process 4140
[Thu Jun 15 17:29:35 2006] [notice] Child 4140: Child process is running
[Thu Jun 15 17:29:35 2006] [notice] FastCGI: process manager initialized
[Thu Jun 15 17:29:35 2006] [crit] (OS 3)Systemet finner ikke angitt
bane. : FastCGI: can’t start server
“C:/Website/pagina/public/dispatch.fcgi”: spawn_fs_process() failed
[Thu Jun 15 17:29:36 2006] [notice] Child 2948: Released the start mutex
[Thu Jun 15 17:29:36 2006] [notice] Child 4140: Acquired the start
mutex.
[Thu Jun 15 17:29:36 2006] [notice] Child 4140: Starting 250 worker
threads.
[Thu Jun 15 17:29:37 2006] [notice] Child 2948: Waiting for 250 worker
threads to exit.
[Thu Jun 15 17:29:37 2006] [notice] Child 2948: All worker threads have
exited.
[Thu Jun 15 17:29:38 2006] [notice] Child 2948: Child process is exiting
[Thu Jun 15 17:29:45 2006] [crit] (OS 3)Systemet finner ikke angitt
bane. : FastCGI: can’t start server
“C:/Website/pagina/public/dispatch.fcgi”: spawn_fs_process() failed
[Thu Jun 15 17:29:55 2006] [crit] (OS 3)Systemet finner ikke angitt
bane. : FastCGI: can’t start server
“C:/Website/pagina/public/dispatch.fcgi”: spawn_fs_process() failed

Roland M. wrote:

If I were you, I would move to SCGI and forget FCGI and its numerous
config issues.

Another quickfix would be using mongrel_rails… Just proxy the requests
from apache.

Could you post the error message in log/production.log or
log/development.log?

Are you able to run webrick ?

Roland

First… im able to run webrick, but nothing loads, and it gets a
timeout…
the dev.log is only a long binary empty space!! about 5mb!!

I think im going to go over to scgi, do you have a good easy tutorial
for setting scgi with apache andr rails on windows?

thanks…

If I were you, I would move to SCGI and forget FCGI and its numerous
config issues.

Another quickfix would be using mongrel_rails… Just proxy the requests
from apache.

Could you post the error message in log/production.log or
log/development.log?

Are you able to run webrick ?

Roland

Herman:
Again, see my articles, especially the one on using Mongrel behind
Apache.
There are several methods for deployment there. If your application is
supporting a small number of users, you can use Mongrel and run it as a
Windows service.

http://www.napcs.com/howto/rails/deploy/

However, if you want to use Apache with SCGI, I suggest checking out
InstantRails.