A
Aredridel
I've just been trying to make ruby work as an external FastCGI
process, rather than one spawned by the webserver.
I've got some hackish code (also at
http://www.rubygarden.org/ruby?FCGIExternalServer) that works, but
only with the pure-ruby version of fcgi-0.8.5
FCGI_PURE_RUBY=true; require 'fcgi'
require 'socket'
def handleConnection(request)
request.out.puts "Content-type: text/html"
request.out.print "\r\n"
request.out.puts "Hello World"
request.finish
end
socket = UNIXServer.new('/tmp/fcrb_socket')
class << socket
alias ldaccept :accept
def accept
[oldaccept, nil]
end
end
FCGI::Server.new(socket).each_request do |request|
Thread.start {handleConnection(request)}
end
Has anyone used the C version to do this? Is there an easier way?
Any suggestions for ways to make the API better? I don't mind putting
work into what might become a new version of fcgi, but I'd love to
avoid re-implementing the wheel.
Ari
process, rather than one spawned by the webserver.
I've got some hackish code (also at
http://www.rubygarden.org/ruby?FCGIExternalServer) that works, but
only with the pure-ruby version of fcgi-0.8.5
FCGI_PURE_RUBY=true; require 'fcgi'
require 'socket'
def handleConnection(request)
request.out.puts "Content-type: text/html"
request.out.print "\r\n"
request.out.puts "Hello World"
request.finish
end
socket = UNIXServer.new('/tmp/fcrb_socket')
class << socket
alias ldaccept :accept
def accept
[oldaccept, nil]
end
end
FCGI::Server.new(socket).each_request do |request|
Thread.start {handleConnection(request)}
end
Has anyone used the C version to do this? Is there an easier way?
Any suggestions for ways to make the API better? I don't mind putting
work into what might become a new version of fcgi, but I'd love to
avoid re-implementing the wheel.
Ari