To use the CGIServlet in FastCGI mode there will need to be a FastCGI server process running somewhere, listening for FastCGI requests.
The FastCGILauncher is a ServletContextListener that will start and stop an external process. It will also monitor the process and restart it when it stops.
The FastCGILauncher is configured through context-params with names beginning with "FCGI_Launcher.[name]" where [name] is a way to relate parameters for a particular process to start. In this way the launcher can manage multiple processes.
The command to exec. This will be split into process arguments by whitespace. There is no quoting.
Time in milliseconds to delay between exit and restarting. Only applies if the process exits within this period after starting.
true/false. Default true. The output of the process will be logged by its own thread. If this is false a separate thread will be used to handle stderr output.
param will be passed as the value for ENVIRONMENT_VAR in the process environment.
The example below starts up a php fastcgi server on port 7543, it also passes the environment variable PHP_FCGI_MAX_REQUESTS, which causes the php process to exit after 1000 requests. The FCGI_Launcher watchdog will restart it immediately.
<!-- ================================================================= --> <!-- Run PHP in FastCGI mode and make sure it keeps running --> <!-- ================================================================= --> <listener> <display-name>FastCGILauncher</display-name> <listener-class> au.com.lastweekend.cgi.FastCGILauncher </listener-class> </listener> <context-param> <param-name>FCGI_Launcher.php.command</param-name> <param-value>/usr/bin/php-cgi -b localhost:7543</param-value> </context-param> <context-param> <param-name>FCGI_Launcher.php.env.PHP_FCGI_MAX_REQUESTS</param-name> <param-value>1000</param-value> </context-param>
See also the FastCGILauncher javadoc for usage info.