FCGI.pm?

I’m trying to learn how to use the fastcgi-wrapper.pl from this link:
http://www.ruby-forum.com/topic/145858

  1. This requires FCGI.pm. The only one I found on cpan.org throws a
    great many errors when I try to run perl fast-cgi-wrapper.pl. Where
    should I get this from? I’m running perl 5.8.8.

  2. I have one component on one site that does some AJAX to call a perl
    backend. Should this fastcgi-wrapper.pl work for me? I can’t really
    find any docs that explain how to use it. I’m not really a perl person
    (mostly PHP).

Thanks,
Chris

look into fcgiwrap

http://nginx.localdomain.pl/wiki/FcgiWrap
http://www.ruby-forum.com/topic/148328

i haven’t tried it yet but looked a lot easier/cleaner

On Thu, Feb 26, 2009 at 12:40 AM, Chris Cortese

Thanks.

I can’t seem to build this though for Fedora 8.

I get fcgiwrap.c:4:24: error: fcgi_stdio.h: No such file or directory
cc1: warnings being treated as errors

I understand that I need libfcgi. So I downloaded and installed:
rpm -i fcgi-2.4.0-6.fc8.x86_64.rpm

No change.

Any idea what I’m doing wrong?

rpm -ql fcgi |grep fcgi_stdio.h

if it is not somewhere the c compiler expect it to be …create a symlink

On Thu, Feb 26, 2009 at 4:35 PM, Chris Cortese
<[email protected]

On czw, lut 26, 2009 at 02:09:20 -0800, Chris Cortese wrote:

ftp://rpmfind.net/linux/fedora/updates/8/x86_64.newkey/fcgi-2.4.0-6.fc8.x86_64.rpm

Any other place to find this stuff?

I don’t use Fedora but try installing fcgi-devel (I guess that’s the
right package name) as well as fcgi. You need the headers (fcgi-devel)
to compile fcgiwrap and the binaries (fcgi) to run it.

Best regards,
Grzegorz N.

Thanks. That got me a little closer.

Now, I have built fcgiwrap but I don’t know how to use it. From the
http://nginx.localdomain.pl/wiki/FcgiWrap page, can anyone elaborate on
what the following means?

You can then start fcgiwrap (possibly in several instances) using
spawn-fcgi or a similar tool (you must pass an open socket as fd 0; my
Spawner? will be very nice for this once I actually make it usable and
publish it) and send requests to it using fastcgi_pass. That’s it.

Thanks.

The way I am using it (and the credit ALL goes to Grzegorsz who helped
me a great deal with it) on CentOS is to use the Perl script on that
page (http://nginx.localdomain.pl/wiki/FcgiWrap).

Then you add the following to the site config:

location ~ .pl$ {
fastcgi_pass unix:/tmp/cgi.sock;
include /usr/local/nginx/conf/fastcgi_params;
}

You can adjust the number of child processes to suit your needs.

On Thu, Feb 26, 2009 at 03:11:24AM -0800, Chris Cortese wrote:

Thanks. That got me a little closer.

Now, I have built fcgiwrap but I don’t know how to use it. From the
http://nginx.localdomain.pl/wiki/FcgiWrap page, can anyone elaborate on
what the following means?

You can then start fcgiwrap (possibly in several instances) using
spawn-fcgi or a similar tool (you must pass an open socket as fd 0; my
Spawner? will be very nice for this once I actually make it usable and
publish it) and send requests to it using fastcgi_pass. That’s it.

Yup. Providing the socket for fcgiwrap to listen on is your problem
(fcgiwrap doesn’t care whether it is a tcp socket or a unix domain one
etc.). The simplest way to run a single fcgiwrap is to use spawn-fcgi,
like this:

spawn-fcgi -f /usr/local/bin/fcgiwrap -a 127.0.0.1 -p 8001

or

spawn-fcgi -f /usr/local/bin/fcgiwrap -S /tmp/cgi.sock

If you want to run multiple instances, give the Perl launcher from my
website a try.

Best regards,
Grzegorz N.

I am still not finding this fcgi_stdio.h anywhere.

I went to these links:
http://rpmfind.net/linux/rpm2html/search.php?query=libfcgi.so.0()(64bit)
http://rpmfind.net/linux/RPM/fedora/updates/8/x86_64/debug/fcgi-debuginfo-2.4.0-6.fc8.x86_64.html

I tried installing:

ftp://download.fedora.redhat.com/pub/fedora/linux/updates/8/SRPMS.newkey/fcgi-2.4.0-6.fc8.src.rpm
ftp://rpmfind.net/linux/fedora/releases/8/Everything/x86_64/os/Packages/fcgi-2.4.0-4.fc8.x86_64.rpm
ftp://rpmfind.net/linux/fedora/updates/8/x86_64.newkey/fcgi-2.4.0-6.fc8.x86_64.rpm

Any other place to find this stuff?

Thanks…

On Thu, Feb 26, 2009 at 4:03 AM, Grzegorz N.
[email protected] wrote:

Yup. Providing the socket for fcgiwrap to listen on is your problem
(fcgiwrap doesn’t care whether it is a tcp socket or a unix domain one
etc.). The simplest way to run a single fcgiwrap is to use spawn-fcgi,
like this:

spawn-fcgi -f /usr/local/bin/fcgiwrap -a 127.0.0.1 -p 8001

or

spawn-fcgi -f /usr/local/bin/fcgiwrap -S /tmp/cgi.sock

Oh? spawn-fcgi will work too? Not the perl-based example? Cool. That
made life a little bit easier for me as I have scripts and things that
I had made to control spawn-fcgi stuff.

I’m still excited for a php-fpm style management daemon though :slight_smile:

I will need to try spawn-fcgi + fcgiwrap soon!

What about the nginx equivalent for the Apache ScriptAlias directive for
cgi-bin?

I’m running fcgiwrap and have the following in my site config:

location ~ .pl$ {
fastcgi_pass unix:/tmp/cgi.sock;
include /etc/nginx/fastcgi_params;
}

My directory structure is like: (higher up part of the path omitted for
simplicity)
/trunk/cgi-bin
/trunk/html/public/index.php

If I want to call http://mysite.com/cgi-bin/upload.pl … How can I
tell nginx where to find this?

Thanks,
Chris

luben wrote:

. It expects to have “run” method for handling the request
(CGI::Application integration) but you could change the expected
method name in the code to integrate with different platforms. I could
even make it an option if there is a need.

After sending the message I found that I have already made the handler
method an option.

On Thu, 2009-02-26 at 01:35 -0800, Chris Cortese wrote:

Thanks.

I can’t seem to build this though for Fedora 8.

I get fcgiwrap.c:4:24: error: fcgi_stdio.h: No such file or directory
cc1: warnings being treated as errors

I understand that I need libfcgi. So I downloaded and installed:
rpm -i fcgi-2.4.0-6.fc8.x86_64.rpm

On Redhat systems you need the -devel RPM, probably fcgi-devel.

Cliff

Some while ago I had problems starting perl fcgi processes and the
example code didn’t worked for me. So I whote a little fcgi launcher,
optimized for perl applications.

You could find it attached to the message. It expects to have “run”
method for handling the request (CGI::Application integration) but you
could change the expected method name in the code to integrate with
different platforms. I could even make it an option if there is a need.

Use the code freely.

oh, dur. I would need one

spawn-fcgi fcgiwrap etc …

for -every- “child” instance available. since it only does PHP
children itself, yeah?

Unless it has changed in the latest version (I haven’t looked at the
documentation), spawn-fcgi’s “-c” option only applies to php-cgi
processes. I tried it with fcgiwrap and got only one instance. Using the
script that Grzegorz wrote you can generate as many as you like, and
they are cheap memory-wise.

Sent from my Verizon Wireless BlackBerry

fcgiwrap is slowly becoming a must have in my toolbox :slight_smile:

hopefully soon i will start using it in production. want to get
comfortable with it first.

On Sat, Feb 28, 2009 at 4:17 AM, Grzegorz N.

On czw, lut 26, 2009 at 02:20:18 -0800, mike wrote:

oh, dur. I would need one

spawn-fcgi fcgiwrap etc …

for -every- “child” instance available. since it only does PHP
children itself, yeah?

It’s your lucky day :wink: Grab a new fcgiwrap snapshot and run it like:

spawn-fcgi (…) – fcgiwrap -c 10

to have 10 processes preforked (the pool has a static size). This code
is rather experimental (may not survive a
kill-all-children-in-a-tight-loop
test) but looks like it’s working.

Best regards,
Grzegorz N.

On Tue, Mar 3, 2009 at 1:45 PM, Roger H. [email protected]
wrote:

Supervisord can do all this and more. It’s a full service process manager
that can manage daemons in any language, including pools of FastCGI
processes.

http://supervisord.org/

Isn’t this somewhat like daemontools, or upstart? (Just with a few
more bells and whistles?)

Without having used daemontools or upstart myself, I think those tools
are
intended to manage machine-level services and don’t support pools of
identical processes nor FastCGI spawning. Supervisord is more geared
toward
running application daemons which may have a different lifecycle. If
you
have different groups of related processes in your application, you can
easily run each group under it’s own instance of supervisord. If you
run
FCGI processes in multiple languages, you don’t need a separate process
manager for each language. If you run different kinds of deamons (like
FCGI,
STOMP, or AMQP), you don’t need a separate process manager for each type
of
daemon. Unlike spawn-fcgi (which is not really a process manager),
supervisord allows a pool of processes to share a single FCGI socket.

mod_fastcgi for Apache is both an FastCGI dispatcher and a process
manager.
When people switch to nginx, they often struggle with how to manage
their
processes and if they’re not using php-fpm, they often turn to
spawn-fcgi,
which is very much lacking. As it stands, supervisord can fill the gap
perfectly for mod_fastcgi’s process manager for statically configured
processes.

For dynamically spawned processes, if someone were willing to write an
nginx
module to call supervisord’s XML-RPC api, we’d have a complete,
language-agnostic replacement solution for mod_fastcgi.