Skip to content
Snippets Groups Projects
Commit 8018cbe2 authored by Guillaume ROUSSE's avatar Guillaume ROUSSE
Browse files

perform sanity check later, so as to gracefully fails if needed

parent 75735670
No related branches found
No related tags found
No related merge requests found
...@@ -13,16 +13,6 @@ my $configuration_file = ...@@ -13,16 +13,6 @@ my $configuration_file =
$ENV{ACCOUNTMANAGER_CONFIG} || '@sysconfdir@/manager.conf'; $ENV{ACCOUNTMANAGER_CONFIG} || '@sysconfdir@/manager.conf';
my $configuration = Config::Tiny->read($configuration_file); my $configuration = Config::Tiny->read($configuration_file);
# configuration sanity check
die "no database defined in configuration, aborting\n"
unless $configuration->{database};
die "no mailer defined in configuration, aborting\n"
unless $configuration->{mailer};
die "no idp defined in configuration, aborting\n"
unless $configuration->{idp};
warn "no logger in configuration, logging disabled\n"
unless $configuration->{logger};
my $app = AccountManager::App->new( my $app = AccountManager::App->new(
configuration => $configuration configuration => $configuration
); );
......
...@@ -54,20 +54,62 @@ sub new { ...@@ -54,20 +54,62 @@ sub new {
$self->{configuration}->{logger}->{file}, $self->{configuration}->{logger}->{file},
log_level => $self->{configuration}->{logger}->{level} log_level => $self->{configuration}->{logger}->{level}
); );
} else {
warn "no logger in configuration, logging disabled\n";
} }
$self->{logger} = Log::Any->get_logger(); $self->{logger} = Log::Any->get_logger();
AccountManager::DB->register_db( $self->{cgi} = CGI->new();
driver => $self->{configuration}->{database}->{type},
database => $self->{configuration}->{database}->{name}, if (!$self->{configuration}->{mailer}) {
host => $self->{configuration}->{database}->{host}, $self->{logger}->fatal(
username => $self->{configuration}->{database}->{username}, "No mailer defined in configuration, aborting"
password => $self->{configuration}->{database}->{password}, );
); $self->respond(
template => 'index.tt2.html',
data => {
content => 'errors.tt2.html',
errors => [ 'internal' ]
}
);
}
if (!$self->{configuration}->{idp}) {
$self->{logger}->fatal(
"No IDP defined in configuration, aborting"
);
$self->respond(
template => 'index.tt2.html',
data => {
content => 'errors.tt2.html',
errors => [ 'internal' ]
}
);
}
if ($self->{configuration}->{logger}) {
AccountManager::DB->register_db(
driver => $self->{configuration}->{database}->{type},
database => $self->{configuration}->{database}->{name},
host => $self->{configuration}->{database}->{host},
username => $self->{configuration}->{database}->{username},
password => $self->{configuration}->{database}->{password},
);
} else {
$self->{logger}->fatal(
"No database defined in configuration, aborting"
);
$self->respond(
template => 'index.tt2.html',
data => {
content => 'errors.tt2.html',
errors => [ 'internal' ]
}
);
}
$self->{db} = AccountManager::DB->new(); $self->{db} = AccountManager::DB->new();
$self->{cgi} = CGI->new();
bless $self, $pkg; bless $self, $pkg;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment