[Dancer-users] Dancer + Plack/Starman - location of .psgi matters?

Richard Huxton dev at archonet.com
Mon May 9 20:45:18 CEST 2011

On 09/05/11 12:24, Takeshi OKURA wrote:
> 2011/5/7 Richard Huxton<dev at archonet.com>:
>> This works:
>>   starman -E development -a bin/app.development.psgi ...
>> This doesn't (complains about config not being loaded):
>>   starman -E development -a res/app.development.psgi ...
> Dancer.pm have a below code in sub _init_script_dir.
> So, bin and public dir are special case which appdir is set to one
> level upper path.

Aha - I thought something like that must be happening. Thanks very much 
for this pointer.

> You may work around the problem to set DANCER_APPDIR environment
> variable. for example
> DANCER_APPDIR=`pwd` starman -E development -a res/app.development.psgi ...

Hmm - looks like a documentation patch might be useful, since I don't 
remember seeing DANCER_APPDIR mentioned anywhere.

Hmm - it's not possible to set this simply in the .psgi because it's 
needed at "use" time. So - this doesn't work:
     $ENV{DANCER_APPDIR} = "/srv/Projects/oldford_db/src/tmp/test1";
     use Dancer;
     ...rest of script...
But this does:
     BEGIN {
         $ENV{DANCER_APPDIR} = "/srv/Projects/oldford_db/src/tmp/test1";
     use Dancer;
     ...rest of script...

Would there be any interest in some elements of the following?

1. Have an explicit appdir (syntax just a suggestion)
    use Dancer appdir=>'/path/to/myapp'
2. If that isn't provided, check ENV as at present
3. If that isn't provided, try based on script dir
    Be a bit stricter than at present, perhaps check for:
    bin/ && public/ && config.yml
4. If that fails, die and explain why.

I think steps #3,4 are valuable in themselves. If my app had just died 
and told me to check the docs re: appdir then that would have saved me 
any pain.

   Richard Huxton
   Archonet Ltd

More information about the Dancer-users mailing list