Uniq status daemon for Nginx (#595)

NB: not uniq for Apache for now
This commit is contained in:
Xavier Guimard 2018-06-11 22:11:18 +02:00
parent 492296c226
commit 019f1e75e8
4 changed files with 13 additions and 13 deletions

View File

@ -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';

View File

@ -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;
}

View File

@ -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} ) ) {

View File

@ -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 {