FCGI::Engine(3pm) | User Contributed Perl Documentation | FCGI::Engine(3pm) |
FCGI::Engine - A flexible engine for running FCGI-based applications
# in scripts/my_web_app_fcgi.pl use strict; use warnings; use FCGI::Engine; FCGI::Engine->new_with_options( handler_class => 'My::Web::Application', handler_method => 'run', pre_fork_init => sub { require('my_web_app_startup.pl'); } )->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 \ --listen /tmp/my_app.socket --daemon # see also FCGI::Engine::Manager for managing # multiple FastCGI backends under one script
This module helps manage FCGI based web applications by providing a wrapper which handles most of the low-level FCGI details for you. It can run FCGI programs as simple scripts or as full standalone socket based servers who are managed by FCGI::Engine::ProcManager.
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.
This module (FCGI::Engine) is not 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 FCGI 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.
As of version 0.11 we now have Plack/PSGI applications support via the FCGI::Engine::Manager::Server::Plackup module. See that module for more information about how it can be used.
This module uses CGI::Simple as a sane replacement for CGI.pm, it will pass in a CGI::Simple instance to your chosen "handler_method" 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 CGI.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.
If you want to change this behavior and not use CGI::Simple then you can override this using the "handler_args_builder" option, see the docs on that below for more details.
This module is *NIX only, it definitely does not work on Windows and I have no intention of making it do so. Sorry.
This module uses MooseX::Getopt for command line parameter handling and validation.
All parameters are currently optional, but some parameters depend on one another.
In addition to the command line parameters, there are a couple parameters that the constructor expects.
It passes the %addtional_options arguments to both the "pre_fork_init" sub and as constructor args to the "proc_manager".
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.
Stevan Little <stevan@iinteractive.com>
Contributions from:
Marcus Ramberg
Bradley C. Bailey
Brian Cassidy
Johannes Plunien
Copyright 2007-2010 by Infinity Interactive, Inc.
<http://www.iinteractive.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
2022-12-10 | perl v5.36.0 |