Commit d4a614bc authored by Keith Jolley's avatar Keith Jolley
Browse files

Add PSGI file to run REST interface from PSGI servers.

parent 423fcea5
#!/usr/bin/perl -T #!/usr/bin/perl
#bigsrest.pl REST interface for BIGSdb #bigsrest.pl REST interface for BIGSdb
#Written by Keith Jolley #Written by Keith Jolley
#Copyright (c) 2014, University of Oxford #Copyright (c) 2014, University of Oxford
...@@ -30,21 +30,24 @@ use constant { ...@@ -30,21 +30,24 @@ use constant {
HOST => 'localhost', HOST => 'localhost',
PORT => 5432, PORT => 5432,
USER => 'apache', USER => 'apache',
PASSWORD => '' PASSWORD => '',
URI_BASE => 'http://rest.pubmlst.org/'
}; };
#######End Local configuration################################ #######End Local configuration################################
use Log::Log4perl qw(get_logger); #Also need Log::Dispatch::File use Log::Log4perl qw(get_logger); #Also need Log::Dispatch::File
use lib (LIB_DIR); use lib (LIB_DIR);
use BIGSdb::REST::Interface; use BIGSdb::REST::Interface;
Log::Log4perl->init_once( CONFIG_DIR . '/rest_logging.conf' ); Log::Log4perl->init_once( CONFIG_DIR . '/rest_logging.conf' );
BIGSdb::REST::Interface->new( my $app = BIGSdb::REST::Interface->new(
{ {
config_dir => CONFIG_DIR, config_dir => CONFIG_DIR,
lib_dir => LIB_DIR, lib_dir => LIB_DIR,
dbase_config_dir => DBASE_CONFIG_DIR, dbase_config_dir => DBASE_CONFIG_DIR,
uri_base => URI_BASE,
host => HOST, host => HOST,
port => PORT, port => PORT,
user => USER, user => USER,
password => PASSWORD password => PASSWORD
} }
); );
$app->dance;
#!/usr/bin/env perl
use strict;
use warnings;
BEGIN { $ENV{DANCER_APPHANDLER} = 'PSGI';}
use Dancer2;
use FindBin '$RealBin';
use Plack::Runner;
# 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';
my $psgi = path($RealBin, 'bigsrest.pl');
die "Unable to read startup script: $psgi" unless -r $psgi;
Plack::Runner->run($psgi);
...@@ -32,6 +32,7 @@ use BIGSdb::REST::Routes::Resources; ...@@ -32,6 +32,7 @@ use BIGSdb::REST::Routes::Resources;
use BIGSdb::REST::Routes::Schemes; use BIGSdb::REST::Routes::Schemes;
use BIGSdb::REST::Routes::Users; use BIGSdb::REST::Routes::Users;
use constant PAGE_SIZE => 100; use constant PAGE_SIZE => 100;
set behind_proxy => 1;
sub new { sub new {
my ( $class, $options ) = @_; my ( $class, $options ) = @_;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment