Commit e51c39cf authored by Xavier Guimard's avatar Xavier Guimard

Enable custom functions with FastCGI server (#583)

parent 91228b57
......@@ -10,3 +10,6 @@ PID=/var/run/llng-fastcgi-server/llng-fastcgi-server.pid
# User and GROUP
USER=www-data
GROUP=www-data
# Custom functions file
#CUSTOM_FUNCTIONS_FILE=/var/lib/lemonldap-ng/myfile.pm
......@@ -37,6 +37,10 @@ fi
DAEMON_OPTS="-p ${PID} -u ${USER} -g ${GROUP} -s ${SOCKET}"
if [ -z "$CUSTOM_FUNCTIONS_FILE" ]; then
DAEMON_OPTS="$DAEMON_OPTS -f ${CUSTOM_FUNCTIONS_FILE}"
fi
start_server() {
# Start the daemon/service
#
......
......@@ -10,3 +10,6 @@ PID=__FASTCGISOCKDIR__/llng-fastcgi-server.pid
# User and GROUP
USER=__USER__
GROUP=__GROUP__
# Custom functions file
#CUSTOM_FUNCTIONS_FILE=/var/lib/lemonldap-ng/myfile.pm
......@@ -37,6 +37,10 @@ fi
DAEMON_OPTS="-p ${PID} -u ${USER} -g ${GROUP} -s ${SOCKET}"
if [ -z "$CUSTOM_FUNCTIONS_FILE" ]; then
DAEMON_OPTS="$DAEMON_OPTS -f ${CUSTOM_FUNCTIONS_FILE}"
fi
start_server() {
# Start the daemon/service
#
......
......@@ -10,13 +10,14 @@ use Lemonldap::NG::Handler::SharedConf;
our %opts;
my %_apps;
getopts( 'Fn:p:s:u:g:', \%opts );
getopts( 'Fn:p:s:u:g:f:', \%opts );
$opts{n} ||= $ENV{NPROC} || 7;
$opts{p} ||= $ENV{PID} || '__FASTCGISOCKDIR__/llng-fastcgi.pid';
$opts{s} ||= $ENV{SOCKET} || '__FASTCGISOCKDIR__/llng-fastcgi.sock';
$opts{u} ||= $ENV{USER};
$opts{g} ||= $ENV{GROUP};
$opts{f} ||= $ENV{CUSTOM_FUNCTIONS_FILE};
if ( $opts{g} ) {
my $grp = getgrnam( $opts{g} ) or warn "Can't change uid to $opts{g}";
......@@ -28,6 +29,11 @@ if ( $opts{u} ) {
POSIX::setuid($uid);
}
if($opts{f}) {
eval {require $opts{f}};
die $@ if($@);
}
my %builder = (
handler => sub {
require Lemonldap::NG::Handler::Nginx;
......@@ -68,6 +74,9 @@ my $app = sub {
die "Unknown PSGI type $type";
};
# Hook for customFunctions initialization
use Lemonldap::NG::Handler::API::PSGI::Server;
$Lemonldap::NG::Handler::API::mode = 'PSGI::Server';
Lemonldap::NG::Handler::SharedConf->init();
my $server = Plack::Runner->new();
......
......@@ -5,6 +5,7 @@ use strict;
use base 'Lemonldap::NG::Handler::API::PSGI';
*cgiName = *Lemonldap::NG::Handler::API::PSGI::cgiName;
*uri_with_args = *Lemonldap::NG::Handler::API::PSGI::uri_with_args;
# In server mode, headers are not passed to a PSGI application but returned
# to the server
......
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