-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathepico-rest.fcgi
executable file
·42 lines (32 loc) · 1.07 KB
/
epico-rest.fcgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/perl -w
# BLUEPRINT Data Analysis Portal REST API
# José María Fernández ([email protected])
use strict;
use warnings 'all';
BEGIN { $ENV{DANCER_APPHANDLER} = 'PSGI';}
use Dancer2;
use Dancer2::FileUtils;
use File::Spec;
use FindBin;
# For some reason Apache SetEnv directives don't propagate
# correctly to the dispatchers, so forcing PSGI and env here
# is safer.
set apphandler => 'PSGI';
set environment => 'production';
# Removing the extension
my $psgi = Dancer2::FileUtils::path(File::Spec->catfile($FindBin::Bin, $FindBin::Script));
my($volume,$directories,$file) = File::Spec->splitpath($psgi);
my $rdot = rindex($file,'.');
if($rdot != -1) {
$file = substr($file,0,$rdot);
$psgi = File::Spec->catpath($volume,$directories,$file);
}
# Adding the new extension
$psgi .= '.psgi';
die "Unable to find EPICO REST API script: $psgi" unless(-r $psgi);
# This is for FastCGI
use Plack::Handler::FCGI;
my $app = do($psgi);
die "Unable to parse EPICO REST API script: $@" if $@;
my $server = Plack::Handler::FCGI->new(nproc => 5, detach => 1);
$server->run($app);