Well, there's been one request about FastCGI, so here's the scoop:
(1) Get the development kit from http://www.fastcgi.com
Currently, it is http://www.fastcgi.com/dist/fcgi-2.2.2.tar.gz
(2) save it to your hp and do the usual:
gunzip <fcgi-2.2.2.tar.gz | tar xvopf -
In the file libfcgi/os_unix.c, change fcntl to sfcntl each time it's called.
Do this:
CC=gcc \
CPPFLAGS="-D_POSIX_SOURCE -D_SOCKET_SOURCE" \
LDFLAGS="-lsocket" ./configure
(You can also use CC=c89)
Then "make".
If you are using C or Perl, you can use the documentation at the FastCGI
website to create programs. Basically, your programs will look like this:
initialize (e.g. open datasets)
while (FCGI_Accept() > 0) {
process just like normal CGI program
}
This will loop once for each request.
A program that's compiled for FastCGI can also work as a regular CGI program
(good for testing).
Now, how do you run it as a FastCGI program?
Either (1) use mod_fcgi in apache or (2) use the cgi-fcgi program.
(1) I have not used mod_fcgi because we are running Apache 1.3.9 on MPE/iX
6.0 and it doesn't support DSOs. Theoretically, it should work with small
changes.
(2) Use cgi-fcgi
You write a tiny forwarding program in cgi-bin, e.g.
#! /APACHE/PUB/cgi-bin/cgi-fcgi -f
-bind -connect localhost:9096
That will forward your cgi requests to a FastCGI program waiting on socket
9096 (Any unused socket # >1024 is okay).
Then, in another job, you run your program with some kind of monitor that
opens the socket then runs your program. The program 'cgi-fcgi' will also
do this, although you need to make one change for MPE/iX. You probably want
to have some way to monitor if your program dies unexpectedly and possibly
restart it. That is something that "cgi-fcgi" does not do, although
mod_fcgi does.
Also, cgi-fcgi does no security checking (mod_fcgi does). If you are running
on an IP socket, especially, you may want to check who connected to you. I
have not tried using Unix domain sockets.
E.g.
cgi-fcgi -start -connect localhost:9096 /YOUR/PROGRAM/HERE
Miscellaneous:
The easiest way to link is to use gcc or c89, including
libfcgi/.libs/libfcgi.a
For Perl, see FCGI.pm and FCGI-ProcManager (I haven't tried it)
For COBOL, I created C stub routines to call from COBOL. I had to use a C
outer block to get stdio to initialize correctly. I linked with
c89 -o testfcgi fcgistub.o testfcgi.o libfcgi/.libs/libfcgi.a -lsocket
where testfcgi.o was a symbolic link to a compiled COBOL object (NMOBJ)
file.
The change to get "cgi-fcgi -start" to work on MPE/iX is:
Change:
if(!doBind) {
exit(0);
} else {
to:
if(!doBind) {
int status;
int errct=0;
while (wait(&status)> 0 || errno != ECHILD) {
if (errct++ > 100) {
exit(1);
}
}
exit(0);
} else {
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|