[Dancer-users] deployment woes (general note)

Mr. Puneet Kishor punk.kish at gmail.com
Mon Jul 4 05:53:40 CEST 2011

Dancer has been out a while now, and is used widely. Yet, I still continue to encounter major difficulties and puzzlement in deploying multiple Dancer apps. I don't believe I have particularly weird requirements, yet, I don't see much noise wrt deployment. That leads me to believe that I am understanding Dancer's deployment mechanism inadequately. Here is my general deployment scenario --

I have a Mac OS X server with Apache, and several "institutional" web sites served off of that. Let's call them 
  /Library/WebServer/Documents/proj1  [http://myserver.edu/proj1]
  /Library/WebServer/Documents/proj2  [http://myserver.edu/proj2]

I don't want to mess with the above at all, and want to tinker with httpd.conf as minimally as possible.

I log into my account on the computer, use perlbrew to install the latest perl under /Users/punkish/perl5, install all my own perl modules including Starman, and make the following Dancer applications

  [1] /Users/punkish/Sites/myapp1  [http://myserver.edu/myapp1]
  [2] /Users/punkish/Sites/myapp2  [http://myapp2.myserver.edu]
  [3] /Users/punkish/Sites/myapp3  [http://myapp3.org]
  [4] /Users/punkish/Sites/myapp4  [http://myapp4.myapp3.org]

[1] appears as just a sub-directory myserver.edu, not unlike proj1 and proj2.

[2] is a sub-domain of myserver.edu

[3] is a completely separate domain

[4] is a sub-domain of [3]

I also have the following as a common location for various JavaScript libraries, and a few css templates, I use for all my apps

  [0] /Users/punkish/Sites/lib  [http://myserver.edu/punkish/lib]
                                [<relative to any app>/lib]

So, I can serve [1] using Starman with the following configuration

## web.psgi
use Dancer ':syntax';
use Plack::Builder;

setting apphandler => 'PSGI';

my $htdocs = '/Users/punkish/Sites';

my $foo = sub {
	my $env = shift;
	local $ENV{DANCER_APPDIR} = "$htdocs/foo";
	setting appdir => "$htdocs/foo";
	load_app "foo";
	my $request = Dancer::Request->new( env => $env );
	Dancer->dance( $request );

builder {
	# The following allows serving files from /lib
	# much like the Alias directive in Apache
	enable "Static", path => sub { s!^/lib/!! }, root => "/Users/punkish/Sites/lib";
	mount "/foo" => builder {$foo};

I can serve [2], [3], and [4] using Apache VirtualHost directive, but can I do that using Starman?


More information about the Dancer-users mailing list