NAME

App::BundleDeps - Bundle All Your Module Deps In A local::lib Dir

SYNOPSIS

use App::BundleDeps;

App::BundleDeps->new()->bundle_from_meta( 'META.yml' );

# or

my @modules = ( $module1, $module2, $module3, ... );
App::BundleDeps->new()->bundle_modules( @modules );

DESCRIPTION

App::BundleDeps is a tool that allows you to "bundle" all your prerequisites in one local::lib installation. This is very useful when you want to deploy your application.

SCENARIO

Here, I'm going to show how to deploy a Catalyst application using App::BundleDeps and daemontools.

So, suppose you checked out / downloaded your production ready application here:

/home/apps/MyApp-0.89

Move to that directory, and create your bundle:

cd /home/apps/MyApp-0.89
perl Makefile.PL NO_META=0
perl -MApp::BundleDeps -e 'App::BundleDeps->new->bundle_from_meta("META.yml");'

You obviously have to have Makefile.PL setup so that it includes all the necessary prerequisites.

At this point you should have a directory named extlib. Now prep your daemontools environemnt like so: First create the necessary directory structure (do it where svscan isn't watching)

mkdir /var/lib/svscan/MyApp-0.89

Now move to that directory, and create a run script file. We'll assume we're deploying a fastcgi server:

#!/bin/sh
MYAPP_DIR=/home/apps/MyApp-0.89
PERL=/usr/local/bin/perl # I like to explicitly declare this, YMMV

# XXX - You may have to specify MYAPP_HOME/MYAPP_CONFIG
exec setuidgid app \
    $PERL \
    -Mlocal::lib=$MYAPP_DIR/extlib \
    $MAYPP_DIR/script/myapp_fastcgi.pl \
    -e \
    -l /path/to/socket \
    2>&1

You should probably set up run script for logging, but see the daemontools manual for that.

Now, create a symlink to where svscan is watching, typically /service or /etc/service:

ln -s /var/lib/svscan/MyApp-0.89 /service/MyApp-0.89

And your service should start.

This is especially useful, because when you come up with MyApp-0.90, you can simply follow the same steps and deploy MyApp-0.90 with its own set of prerequisites (you don't have to care what MyApp-0.89 was using, or what the system installed module versions are!). When you checked that MyApp-0.90 is receiving the requests, just follow the following steps to unstage your previous app:

rm /service/MyApp-0.89
svc -dx /var/lib/svscan/MyApp-0.89
svc -dx /var/lib/svscan/MyApp-0.89/log

Woohoo, done!

CAVEATS

Prerequisites marked as "recommends" are not installed
Tests will not be run

AUTHOR

Daisuke Maki - <daisuke@endeworks.jp>

Miyagawa Tatsuhiko did the actual useful bits.

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://www.perl.com/perl/misc/Artistic.html