.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "FCGI::Engine 3pm" .TH FCGI::Engine 3pm "2021-01-09" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" FCGI::Engine \- A flexible engine for running FCGI\-based applications .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& # in scripts/my_web_app_fcgi.pl \& use strict; \& use warnings; \& \& use FCGI::Engine; \& \& FCGI::Engine\->new_with_options( \& handler_class => \*(AqMy::Web::Application\*(Aq, \& handler_method => \*(Aqrun\*(Aq, \& pre_fork_init => sub { \& require(\*(Aqmy_web_app_startup.pl\*(Aq); \& } \& )\->run; \& \& # run as normal FCGI script \& perl scripts/my_web_app_fcgi.pl \& \& # run as standalone FCGI server \& perl scripts/my_web_app_fcgi.pl \-\-nproc 10 \-\-pidfile /tmp/my_app.pid \e \& \-\-listen /tmp/my_app.socket \-\-daemon \& \& # see also FCGI::Engine::Manager for managing \& # multiple FastCGI backends under one script .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module helps manage \s-1FCGI\s0 based web applications by providing a wrapper which handles most of the low-level \s-1FCGI\s0 details for you. It can run \s-1FCGI\s0 programs as simple scripts or as full standalone socket based servers who are managed by FCGI::Engine::ProcManager. .PP The code is largely based (*cough* stolen *cough*) on the Catalyst::Engine::FastCGI module, and provides a command line interface which is compatible with that module. But of course it does not require Catalyst or anything Catalyst related. So you can use this module with your CGI::Application\-based web application or any other Random::Web::Framework\-based web app. .SS "Using with Catalyst, Plack or other web frameworks" .IX Subsection "Using with Catalyst, Plack or other web frameworks" This module (FCGI::Engine) is \fBnot\fR a replacement for Catalyst::Engine::FastCGI but instead the FCGI::Engine::Manager (and all it's configuration tools) can be used to manager Catalyst apps as well as FCGI::Engine based applications. For example, at work we have an application which has 6 different \s-1FCGI\s0 backends running. Three of them use an ancient in-house web framework with simple FCGI::Engine wrappers, one which uses CGI::Application and an FCGI::Engine wrapper and then two Catalyst applications. They all happily and peacefully coexist and are all managed with the same FCGI::Engine::Manager script. .PP As of version 0.11 we now have Plack/\s-1PSGI\s0 applications support via the FCGI::Engine::Manager::Server::Plackup module. See that module for more information about how it can be used. .SS "Note about \s-1CGI\s0.pm usage" .IX Subsection "Note about CGI.pm usage" This module uses CGI::Simple as a sane replacement for \s-1CGI\s0.pm, it will pass in a CGI::Simple instance to your chosen \f(CW\*(C`handler_method\*(C'\fR for you, so there is no need to create your own instance of it. There have been a few cases from users who have had bad interactions with \s-1CGI\s0.pm and the instance of CGI::Simple we create for you, so before you spend hours looking for bugs in your app, check for this first instead. .PP If you want to change this behavior and not use CGI::Simple then you can override this using the \f(CW\*(C`handler_args_builder\*(C'\fR option, see the docs on that below for more details. .SH "CAVEAT" .IX Header "CAVEAT" This module is *NIX \fBonly\fR, it definitely does not work on Windows and I have no intention of making it do so. Sorry. .SH "PARAMETERS" .IX Header "PARAMETERS" .SS "Command Line" .IX Subsection "Command Line" This module uses MooseX::Getopt for command line parameter handling and validation. .PP All parameters are currently optional, but some parameters depend on one another. .IP "\fI\-\-listen \-l\fR" 4 .IX Item "--listen -l" This should be a file path where the unix domain socket file should live. If this parameter is specified, then you \fBmust\fR also specify a location for the pidfile. .IP "\fI\-\-nproc \-n\fR" 4 .IX Item "--nproc -n" This should be an integer specifying the number of \s-1FCGI\s0 processes that FCGI::Engine::ProcManager should start up. The default is 1. .IP "\fI\-\-pidfile \-p\fR" 4 .IX Item "--pidfile -p" This should be a file path where your pidfile should live. This parameter is only used if the \fIlisten\fR parameter is specified. .IP "\fI\-\-daemon \-d\fR" 4 .IX Item "--daemon -d" This is a boolean parameter and has no argument, it is either used or not. It determines if the script should daemonize itself. This parameter only used if the \fIlisten\fR parameter is specified. .IP "\fI\-\-manager \-m\fR" 4 .IX Item "--manager -m" This allows you to pass the name of a FCGI::ProcManager subclass to use. The default is to use FCGI::Engine::ProcManager, and any value passed to this parameter \fBmust\fR be a subclass of FCGI::ProcManager. .SS "Constructor" .IX Subsection "Constructor" In addition to the command line parameters, there are a couple parameters that the constructor expects. .IP "\fIhandler_class\fR" 4 .IX Item "handler_class" This is expected to be a class name, which will be used inside the request loop to dispatch your web application. .IP "\fIhandler_method\fR" 4 .IX Item "handler_method" This is the class method to be called on the \fIhandler_class\fR to server as a dispatch entry point to your web application. It will default to \f(CW\*(C`handler\*(C'\fR. .IP "\fIhandler_args_builder\fR" 4 .IX Item "handler_args_builder" This must be a \s-1CODE\s0 ref that when called produces the arguments to pass to the \fIhandler_method\fR. It defaults to a sub which returns a CGI::Simple object. .IP "\fIpre_fork_init\fR" 4 .IX Item "pre_fork_init" This is an optional \s-1CODE\s0 reference which will be executed prior to the request loop, and in a multi-proc context, prior to any forking (so as to take advantage of \s-1OS COW\s0 features). .SH "METHODS" .IX Header "METHODS" .SS "Command Line Related" .IX Subsection "Command Line Related" .IP "\fBlisten\fR" 4 .IX Item "listen" Returns the value passed on the command line with \fI\-\-listen\fR. This will return a Path::Class::File object. .IP "\fBis_listening\fR" 4 .IX Item "is_listening" A predicate used to determine if the \fI\-\-listen\fR parameter was specified. .IP "\fBnproc\fR" 4 .IX Item "nproc" Returns the value passed on the command line with \fI\-\-nproc\fR. .IP "\fBpidfile\fR" 4 .IX Item "pidfile" Returns the value passed on the command line with \fI\-\-pidfile\fR. This will return a Path::Class::File object. .IP "\fBhas_pidfile\fR" 4 .IX Item "has_pidfile" A predicate used to determine if the \fI\-\-pidfile\fR parameter was specified. .IP "\fBdetach\fR" 4 .IX Item "detach" Returns the value passed on the command line with \fI\-\-daemon\fR. .IP "\fBshould_detach\fR" 4 .IX Item "should_detach" A predicate used to determine if the \fI\-\-daemon\fR parameter was specified. .IP "\fBmanager\fR" 4 .IX Item "manager" Returns the value passed on the command line with \fI\-\-manager\fR. .SS "Inspection" .IX Subsection "Inspection" .IP "\fBhas_pre_fork_init\fR" 4 .IX Item "has_pre_fork_init" A predicate telling you if anything was passed to the \&\fIpre_fork_init\fR constructor parameter. .SS "Important Stuff" .IX Subsection "Important Stuff" .IP "\fBrun (%addtional_options)\fR" 4 .IX Item "run (%addtional_options)" Call this to start the show. .Sp It passes the \f(CW%addtional_options\fR arguments to both the \&\f(CW\*(C`pre_fork_init\*(C'\fR sub and as constructor args to the \&\f(CW\*(C`proc_manager\*(C'\fR. .SS "Other Stuff" .IX Subsection "Other Stuff" .IP "\fB\s-1BUILD\s0\fR" 4 .IX Item "BUILD" This is the Moose \s-1BUILD\s0 method, it checks some of our parameters to be sure all is sane. .IP "\fBmeta\fR" 4 .IX Item "meta" This returns the Moose metaclass assocaited with this class. .SH "SEE ALSO" .IX Header "SEE ALSO" .IP "Catalyst::Engine::FastCGI" 4 .IX Item "Catalyst::Engine::FastCGI" I took all the guts of that module and squished them around a bit and stuffed them in here. .IP "MooseX::Getopt" 4 .IX Item "MooseX::Getopt" .PD 0 .IP "FCGI::ProcManager" 4 .IX Item "FCGI::ProcManager" .PD I refactored this module and renamed it FCGI::Engine::ProcManager, which is now included in this distro. .SH "BUGS" .IX Header "BUGS" All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. .SH "AUTHOR" .IX Header "AUTHOR" Stevan Little .PP Contributions from: .PP Marcus Ramberg .PP Bradley C. Bailey .PP Brian Cassidy .PP Johannes Plunien .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright 2007\-2010 by Infinity Interactive, Inc. .PP .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.