Commit 019f1e75 authored by Xavier Guimard's avatar Xavier Guimard

Uniq status daemon for Nginx (#595)

NB: not uniq for Apache for now
parent 492296c2
......@@ -53,22 +53,20 @@ if ($user) {
POSIX::setuid($uid);
}
unless ($>) {
die "Refuse to run as root. Aborting";
}
if ($customFunctionsFile) {
eval { require $customFunctionsFile };
die $@ if ($@);
}
my %builder = (
handler => sub {
require Lemonldap::NG::Handler::Server::Nginx;
return Lemonldap::NG::Handler::Server::Nginx->run( {} );
},
reload => sub {
require Lemonldap::NG::Handler::Server::Nginx;
return Lemonldap::NG::Handler::Server::Nginx->reload();
},
status => sub {
require Lemonldap::NG::Handler::Server::Nginx;
return Lemonldap::NG::Handler::Server::Nginx->status();
},
manager => sub {
......@@ -99,9 +97,8 @@ my %builder = (
},
);
unless ($>) {
die "Refuse to run as root. Aborting";
}
require Lemonldap::NG::Handler::Server::Nginx;
$_apps{handler} = Lemonldap::NG::Handler::Server::Nginx->run( {} );
my $app = sub {
my $type = $_[0]->{LLTYPE} || 'handler';
......
......@@ -7,6 +7,8 @@ package Lemonldap::NG::Handler::Main;
use strict;
use Lemonldap::NG::Common::Conf;
our $statusInit = 1;
## @imethod void init(hashRef args)
# Read parameters and build the Lemonldap::NG::Common::Conf object.
# @param $args hash containing parameters
......@@ -40,7 +42,8 @@ sub init($$) {
$class->serverSignatureInit unless ( $class->localConfig->{hideSignature} );
# * launch status process
$class->statusInit() if ( $class->localConfig->{status} );
$class->statusInit() if ( $class->localConfig->{status} and $statusInit );
$statusInit = 0;
1;
}
......
......@@ -33,6 +33,7 @@ sub onReload {
# @return true if config is up to date or if reload config succeeded
sub checkConf {
my ( $class, $force ) = @_;
$class->logger->error("Check configuration for $class");
my $prm = { local => !$force, localPrm => $class->localConfig };
my $conf = $class->confAcc->getConf($prm);
......@@ -54,7 +55,7 @@ sub checkConf {
$class->logger->debug($Lemonldap::NG::Common::Conf::msg);
}
}
if ( !$class->cfgNum or $class->cfgNum != $conf->{cfgNum} ) {
if ( $force or !$class->cfgNum or $class->cfgNum != $conf->{cfgNum} ) {
$class->logger->debug("Get configuration $conf->{cfgNum}");
$class->lastCheck( time() );
unless ( $class->cfgNum( $conf->{cfgNum} ) ) {
......
......@@ -136,8 +136,7 @@ sub init {
# Default routes must point to routines declared above
$self->defaultAuthRoute('');
$self->defaultUnauthRoute('');
return 1;
return $self->api->checkConf(1);
}
sub reloadConf {
......
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