#!/usr/bin/env perl
BEGIN {
$ENV{DANCER_APPHANDLER} = 'PSGI';
# PLACK_ENV seems to be necessary as -initial-env==deployment in apache config
# and 'set environment => production' below fail to load production settings
$ENV{PLACK_ENV} = 'deployment'; # otherwise get development config settings
}
use Dancer2;
use FindBin '$RealBin';
use Plack::Handler::FCGI;
# For some reason Apache SetEnv directives dont propagate
# correctly to the dispatchers, so forcing PSGI and env here
# is safer.
set apphandler => 'PSGI';
set environment => 'production'; # doesn't work (using ENV param in BEGIN block does)
my $psgi = path($RealBin, '..', 'bin', 'app.pl');
my $app = do($psgi);
die "Unable to read startup script: $@" if $@;
my $server = Plack::Handler::FCGI->new(nproc => 2, detach => 1);
$server->run($app);