[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby and Lighttpd/FastCGI

Rüdiger Sonderfeld

7/16/2005 3:20:00 PM

hi,
I'm trying to write a FastCGI script with Ruby and Lighttpd.

I'm using ruby-fcgi 0.8.6, ruby 1.8.2 and lighttpd 1.3.11 (Ubuntu-Linux).

I have setup lighttpd with the following parameters
fastcgi.server = (".rb" =>
( "localhost" =>
( "socket" => "/tmp/rb-fastcgi.socket" )
)
)

I wrote a ruby script similar to
http://www.rubygarden.org/ruby?FCGIExte...

#!/usr/bin/ruby
FCGI_PURE_RUBY=true
require 'socket'
require 'cgi'
require 'fcgi'

socket = UNIXServer.new('/tmp/rb-fastcgi.socket')
class << socket
alias :oldaccept :accept
def accept
[oldaccept, nil]
end
end

FCGI::Server.new(socket).each_request do |request|
Thread.start {
request.out.print "Content-type: text/html\r\n"
request.out.puts "<html><head><title>Foo</title></head><body><b>Yeah</b></body></html>"
request.finish
}
end

I start the script (as user www-data) and restart lighttpd.
But trying to access the script from a browser does not return any results.

lighttpd's errorlog is empty and the http connection is normal.

Any ideas?

Regards,
Rüdiger Sonderfeld <kingruedi@c-plusplus.de>
2 Answers

Aria Stewart

7/16/2005 6:18:00 PM

0

On Sun, 2005-07-17 at 00:25 +0900, Rüdiger Sonderfeld wrote:
> hi,
> I'm trying to write a FastCGI script with Ruby and Lighttpd.
>
> I'm using ruby-fcgi 0.8.6, ruby 1.8.2 and lighttpd 1.3.11 (Ubuntu-Linux).
>
> I have setup lighttpd with the following parameters
> fastcgi.server = (".rb" =>
> ( "localhost" =>
> ( "socket" => "/tmp/rb-fastcgi.socket" )
> )
> )

I always use lighttpd's spawn-fcgi tool for this -- skip the UnixServer
bit in your ruby code, and just do the FCGI.each loop.

Ari



Rüdiger Sonderfeld

7/17/2005 2:23:00 PM

0

Aredridel wrote:
> I always use lighttpd's spawn-fcgi tool for this -- skip the UnixServer
> bit in your ruby code, and just do the FCGI.each loop.

It seems to be a problem within the request code. Even with spawn-fcgi it did
not work until I used the CGI Interface

#!/usr/bin/ruby
require 'cgi'
require 'fcgi'

FCGI.each_cgi do |cgi|
cgi.out("text/html") { "<b>Ruby FCGI</b>" }
end

Thanks a lot.

Regards,
Rüdiger Sonderfeld <kingruedi@c-plusplus.de>