NAME
FCGI::Daemon - an easy to use FastCGI daemon which can be used with nginx web server.
VERSION
Version 0.20110419_01
SYNOPSIS
This is modulino i.e. executable FastCGI daemon.
DESCRIPTION
FCGI::Daemon is a small (Fast)CGI server for use as CGI-wrapper for
unmodified CGI applications.
Factored as modulino, currently it doesn't have any Perl module functionality.
It was developed as replacement for cgiwrap-fcgi.pl ( see http://wiki.nginx.org/SimpleCGI )
FEATURES
* setrlimit for RLIMIT_AS and RLIMIT_CPU
* DOing .pl - run CGI scripts in Perl with persistent interpreter (like mod_perl).
* detection of memory leaks
* drop privileges when run as root
* detection of script executable in path (to run CGI apps like fossil)
USAGE
It can be manually invoked as "perl /usr/share/perl5/FCGI/Daemon.pm"
or with included SysV init script.
Please make sure that user have write permissions for sock file.
OPTIONS
Options: (default arguments given for convenience)
-h # brief help message
-w 1 # number of preforked processes (workers)
-q 96 # max queue
-m 512 # RLIMIT_AS in MiB (see setrlimit)
-c 32 # RLIMIT_CPU in seconds (see setrlimit)
-e 10240 # max evals before process restart. 0 disables DOing perl scripts.
-l 1.3 # memory leak threshold
-p /var/run/fcgid.pid # write pId (process ID) to given file (only if daemonize)
-s /var/run/fcgid.sock # socket file for Fast CGI communication
-u www-data # user name to become (if run as root)
-g www-data # group name to become (if run as root)
-d # daemonize (run in background)
- -e
-
By default FCGI::Daemon DOing .pl scripts up to -e times. This is several times faster than invoking Perl for every call of CGI script. This option define how often parent process should restart. Warning - some scripts may be incompatible with this so disable with "-e0" if necessary.
- -l
-
In DOing mode ( i.e. max_evals > 0 ) worker process terminates if upon CGI execution VmSize/VmRSS < leak treshold.
This is helpful for scripts that are leaking memory
PREREQUISITES
FCGI
FCGI::ProcManager
For Debian GNU/Linux (perhaps the best platform)
required moduled provided by the following packages:
libfcgi-perl
libfcgi-procmanager-perl
COMPATIBILITY
Tested only in GNU/Linux systems. Windows is NOT supported.
NGINX configuration (sample)
location ~ ^/(cgi-)?bin/.*$ {
expires epoch;
gzip off;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/var/run/fcgid.sock;
}
NOTES
Perl scripts can cache persistent data in $_{$0}->{mydata} However if you store too much data it may trigger termination by rlimit After DO/EVAL $_{$0}->{'SIGTERM'} being called so termination handler can be used to close DB connections etc.
$_{$0}->{'SIGTERM'}=sub { print "I closed my handles"; };
FAQ
Why not fcgiwrap? fcgiwrap doesn't pass STDERR to web server for logging.
What's wrong with cgiwrap-fcgi.pl? http://wiki.nginx.org/SimpleCGI Well, many things... * It can't DO perl scripts. * It is written in a strange way which is hard to read and understand. Frankly, it is not very beautiful. * It takes no options so you have to modify the code. * It is incompatible with some CGI applications, notably with fossil.
AUTHOR
Dmitry Smirnov, <onlyjob at cpan.org>
BUGS
Please report any bugs or feature requests to bug-fcgi-daemon at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=FCGI-Daemon. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
During development of this module a bug in Perl was discovered: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=600376 http://rt.perl.org/rt3//Public/Bug/Display.html?id=78436
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc FCGI::Daemon
You can also look for information at:
RT: CPAN's request tracker http://rt.cpan.org/NoAuth/Bugs.html?Dist=FCGI-Daemon
AnnoCPAN: Annotated CPAN documentation http://annocpan.org/dist/FCGI-Daemon
CPAN Ratings http://cpanratings.perl.org/d/FCGI-Daemon
Search CPAN http://search.cpan.org/dist/FCGI-Daemon/
LICENSE
FCGI::Daemon - FastCGI daemon
Copyright (C) 2011 Free Software Foundation
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.