index

gauche-fastcgi

(see also my other gauche-bindings)

What is it:

I improved the version 0.1 (see original README), and call it 0.2 (download, gentoo ebuild). It should work both with gauche-0.8.6 and previous version 0.8.5.

You also need mod_fastcgi (apache module) and fcgi (FCGI server library)

Side note: I extended slightly mod_fastcgi to allow Custom-response: How do I use it?

(format oport "Status: 403\n") 
(format oport "Custom-response: 403#~a\n" url)

What I implemented (in C + stub file)

mod_fastCGI enables 3 modes of cooperation between the Apache server, and the FCGI server: static, dynamic, or external.

My extension of gauche-fastcgi was aimed at enabling the 3rd mode. In this configuration Apache & gauche server are independent, connected by a master socket.

So, ther standalone gauche server needs to construct the master socket:

(fcgx-init)
(let1 socket (fcgx-open-socket port backlog) ; see man listen(2) for backlog 
....
For use with the socket, the C library provides multi-thread ready functions:
(let1 request (fcgx-prepare-request socket flags)
   (fcgx-accept-r request)  ;; more threads can invoke it, 
                            ;; only one will return for 1 request arrived.
   ....
   (fcgx-set-status request 200)
   (fcgx-finish-r request))

fcgx-accept-r makes scheme ports out of the sockets associated with the FCGX_Request, and constructs a hash table for the Environment of the FCGX_Request, it copies the strings!

The best documentation on the C library fcgi is file:///usr/include/fcgiapp.h, in man pages you only have:

Roles

How to convert a CGI application to use FastCGI

I want to warn that these low level applicatoins are almost not used. My main application is (adapted) Kahua.

version 0.1, not multithreaded, provides 2 hi-level calls:

call-with-fastcgi proc

(proc input output error env) ; 

and

(with-fastcgi thunk)

runs thunk with paramenter, and current ports redirected.

I provide:

How to install

My apache2 config:

/linux/2/etc/apache2/commonapache2.conf

Quoting external

The FastCgiExternalServer directive defines filename as an external FastCGI application. If filename does not begin with a slash (/) then it is assumed to be relative to the ServerRoot. The filename does not have to exist in the local filesystem. URIs that Apache resolves to this filename will be handled by this external FastCGI application..

# <IFModule mod_fastcgi.c>
FastCgiExternalServer /var/www/localhost/cgi-gauche/agenzia/virtual  -host linux11:19999  -appConnTimeout 120 -idle-timeout 120
#</IfModule>

And now the useful:

<Directory /var/www/localhost/cgi-gauche/agenzia>
    AllowOverride All
    SetHandler fastcgi-script


# mod_perl used  Access handler!

     FastCgiAccessChecker /var/www/localhost/cgi-gauche/agenzia/virtual
#     FastCgiAccessChecker   /var/www/localhost/cgi-gauche/agenzia/access.scm
     FastCgiAccessCheckerAuthoritative On
 
    Options ExecCGI FollowSymLinks 

# fast cgi does not support Custom failure responses!
    ErrorDocument     403 http://maruska.dyndns.org/login
    ErrorDocument     303 http://maruska.dyndns.org/login?ahoj

    # Allow:
    <IfModule mod_access.c>
      Order allow,deny
      Allow from all
    </IfModule>

</Directory>

example multi-threaded script: http://maruska.dyndns.org/comp/activity/gauche/cgi/server.scm

This would be the "dynamic" type of interraction

... so i don't use it, i use the "external"!
FastCgiConfig -autoUpdate 

<Directory /var/www/localhost/cgi-gauche>
    AllowOverride All
    SetHandler fastcgi-script

    Options ExecCGI FollowSymLinks 

    <IfModule mod_access.c>
      Order allow,deny
      Allow from all
    </IfModule>

</Directory>

New generation TODO

passing file descriptors between processes!

Why do I want it?

step 1 pass-socket in gauche

does the message have to be of non-zero lenght?

pass-fcgi

what needs to be passed over?

Suddenly I had a problem:

http://maruska.gotdns.org/cgi/kahua/pes/edit-ticket?ticket=20568

was getting translated to: PATH_INFO = /edit-ticket