Nginx: FastCGI vs. starman (Erratum)

2 weeks ago I've written Moving my Catalyst Apps from Apache/FCGI to Nginx/Starman

Yesterday I have discussed my setup with mst, jnap and joel on irc.perl.org #catalyst

Here is the gist of what mst had to say.

15:50 <@mst> you're using unix sockets
15:50 <@mst> ergo there's no gain to using starman over fastcgi, you're just using a less efficient protocol
15:51 <@mst> the modern ways are starman via http TCP proxy, and fastcgi via unix socket
15:51 <@mst> you're currently using starman to emulate myapp_fastcgi.pl
15:51 <@mst> and I can't see the point

Here is another post about the same topic. nginx and Perl: FastCGI vs reverse proxy Forget the last downside bullet from the first reply though. thats bogus.

Here is my new setup (debian wheezy, stick to the official deployment instructions if you run into problems with my config)

nginx

server {
    listen 80;
    server_name soundgarden.com *.soundgarden.com;
    client_max_body_size 50m;

    location / {
      include /etc/nginx/fastcgi_params;
      fastcgi_param SCRIPT_NAME '';
      fastcgi_param PATH_INFO $fastcgi_script_name;
      fastcgi_pass unix:/var/www/Soundgarden/soundgarden.socket;
    }

    location /static {
      root /var/www/Soundgarden/root;
      expires 30d;
    }
}

initd

#!/usr/bin/env perl
use warnings;
use strict;
use Daemon::Control;

# 1) create initd file
# ./soundgarden.starman.initd get_init_file > foo
#
# 2) copy to /etc/init.d/cat-soundgarden
# cp foo /etc/init.d/cat-soundgarden
#
# 3) install to runlevels
# update-rc.d cat-soundgarden defaults


my $app_home = '/var/www/Soundgarden';
my $perl     = '/var/www/perl5/perlbrew/perls/perl-5.16.2/bin/perl';
my $program  = $app_home . '/script/soundgarden_fastcgi.pl';
my $name     = 'Soundgarden';
my $workers  = 1;
my $pid_file = $app_home . '/soundgarden.pid';
my $socket   = $app_home . '/soundgarden.socket';

Daemon::Control->new({
    name        => $name,
    lsb_start   => '$nginx',
    lsb_stop    => '$nginx',
    lsb_sdesc   => $name,
    lsb_desc    => $name,
    path        => $app_home . '/soundgarden.fastcgi.initd',

    user        => 'www-data',
    group       => 'www-data',
    directory   => $app_home,
    program     => "$perl $program --nproc $workers --listen $socket",

    pid_file    => $pid_file,
    stderr_file => $app_home . '/soundgarden.out',
    stdout_file => $app_home . '/soundgarden.out',

    fork        => 2,
})->run;

2 Comments

Hello Dave, I just found your article.
I'm also using Debian wheezy to deploy my Catalyst app, but I'm wondering if you just changed www-data user's account from dash to bash?.
My installation comes with /bin/sh (dash) for www-data user and doesn't have source command.

Leave a comment

About davewood

user-pic I like Toast.