[Catalyst] Running system commands under FastCGI with IPC::Cmd / IPC::Run

Ian Sillitoe ian at sillit.com
Thu Oct 21 18:43:12 GMT 2010

I have a Catalyst model that runs a system command as part of a search
facility. The system call only takes a fraction of a second so is processed
inline and this all works fine when tested outside of Catalyst and when
called under the Catalyst standalone server. However, when I deploy it to my
FastCGI environment I have problems - everything seems to work fine apart
from the results of the system call.

The system call is (give or take):

            command =3D> [qw/ blastall -d sequences.db -i input.fa -o
output.results /],
            verbose =3D> 0,
            timeout =3D> 10,

When run under the test server the file 'output.results' contains the
results of the search:

gi|5524211|gb|AAD441661|        pdb|3cx5C00     45.26   285     154
1       1       283     91      375     4e-73    267
gi|5524211|gb|AAD441661|        pdb|2e74A00     33.33   99      65
1       21      118     117     215     9e-16   77.0
gi|5524211|gb|AAD441661|        pdb|2ih2A01     34.78   23      15
0       115     137     85      107     4.0     25.0

When the same application is being run under FastCGI the file is created but
is empty.

The system call was originally being wrapped with IPC::Cmd (via
MooseX::Role::Cmd). I checked what happened when I explicitly used IPC::Run

    my ($in, $out, $err);
    my $success =3D IPC::Run::run [qw/ blastall -d sequences.db -i input.fa=
output.results /], \$in, \$out, \$err, IPC::Run::timeout( 10 );

This works under the test server, but throws the following error under

"Can't locate object method "FILENO" via package "FCGI::Stream" at
/home/ian/perl5/lib/perl5/IPC/Run.pm line 1115.

If I bypass IPC::* and run the system command with backticks then it seems
to work fine under both the test server and FastCGI. However the system call
is happening a long way away from Catalyst - I don't really want to hard
code this with backticks just to get it working under FastCGI.

There seems to be a few different things going on here - I'm not sure
exactly where the problem lies or what might be a red herring - would be
grateful if anyone can help point me in the right direction.



Running FastCGI server on my desktop on port 3001:

  script/my_app_fastcgi.pl -l bsmlx53:3001 -n 3 -p my-app.pid -d

Forwarding requests there from external facing server with the following

  <VirtualHost *:80>
    ServerName      test.foo.com
    DocumentRoot    /home/ian/My-App/trunk/
    ErrorLog        logs/test.foo.com-error_log

    FastCgiExternalServer   /tmp/my-app.fcgi -host bsmlx53:3001

    Alias           /static /home/ian/My-App/trunk/root/static
    Alias           /       /tmp/my-app.fcgi/


  Catalyst::Runtime (5.80029)
  IPC::Run (0.89)
  FCGI (0.67)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20101021/98a03=

More information about the Catalyst mailing list