Commit f38db209 authored by sikeda's avatar sikeda
Browse files

[-dev] Reconnecting database properly when sympa.pl receives HUP signal or...

[-dev] Reconnecting database properly when sympa.pl receives HUP signal or bulk.pl forks slave processes.

git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@11875 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent e1c0b966
......@@ -34,7 +34,6 @@ use Sympa::DatabaseManager;
use Sympa::Language;
use Sympa::List;
use Log;
use SDM;
use Sympa::Template::Compat;
use Sympa::Tools::File;
......
......@@ -28,7 +28,6 @@ use strict;
use warnings;
use Sympa::DatabaseManager;
use Log;
# OBSOLETED. Use $sdm->do_quert directly.
sub do_query {
......
......@@ -36,11 +36,11 @@ use Sympa::Bulk;
use Conf;
use Sympa::Constants;
use Sympa::Crash; # Show traceback.
use Sympa::DatabaseManager;
use Sympa::List;
use Log;
use Sympa::Mailer;
use Sympa::Message;
use SDM;
use tools;
use Sympa::Tools::Daemon;
use Sympa::Tools::Data;
......@@ -261,11 +261,10 @@ while (!$end) {
if (my $r_packets = $bulk->too_much_remaining_packets()
and scalar(@remaining_children) <
$Conf::Conf{'bulk_max_count'}) {
## disconnect from database before fork
## to prevent DB handlers to be shared by different processes
# when loading conf in database disconnect because of sharing
# database handler may crash bulk.pl
SDM::db_disconnect();
# Disconnect from database before fork to prevent DB handles
# to be shared by different processes. Sharing database
# handles may crash bulk.pl.
Sympa::DatabaseManager->disconnect;
if ($Conf::Conf{'bulk_max_count'} > 1) {
Log::do_log(
......@@ -308,6 +307,10 @@ while (!$end) {
}
}
}
# Restore persistent connection.
Sympa::DatabaseManager->instance
or die 'Reconnecting database failed';
}
$last_check_date = time();
}
......
......@@ -54,7 +54,6 @@ use Sympa::Message;
use Sympa::Regexps;
use Sympa::Report;
use Sympa::Scenario;
use SDM;
use tools;
use Sympa::Tools::Daemon;
use Sympa::Tools::Data;
......@@ -1387,10 +1386,10 @@ while ($signal ne 'term') {
## Dump of User files in DB
#Sympa::List::dump();
# Disconnect from Database
SDM::db_disconnect();
if ($signal eq 'hup') {
# Disconnect from Database
Sympa::DatabaseManager->disconnect;
Log::do_log('notice', "Sympa %s reload config",
Sympa::Constants::VERSION);
_load();
......@@ -1407,11 +1406,10 @@ exit(0);
# Load configuration.
sub _load {
## Load sympa.conf.
unless (Conf::load(Conf::get_sympa_conf())) { #Site and Robot
printf STDERR
unless (Conf::load(Conf::get_sympa_conf(), 'no_db')) { #Site and Robot
die sprintf
"Unable to load sympa configuration, file %s or one of the vhost robot.conf files contain errors. Exiting.\n",
Conf::get_sympa_conf();
exit 1;
}
## Open the syslog and say we're read out stuff.
......@@ -1447,6 +1445,20 @@ sub _load {
$Conf::Conf{'etc'};
}
# Check database connectivity.
unless (Sympa::DatabaseManager->instance) {
die sprintf
"Database %s defined in sympa.conf is unreachable. verify db_xxx parameters in sympa.conf\n",
$Conf::Conf{'db_name'};
}
# Now trying to load full config (including database)
unless (Conf::load()) { #FIXME: load Site, then robot cache
die sprintf
"Unable to load Sympa configuration, file %s or any of the virtual host robot.conf files contain errors. Exiting.\n",
Conf::get_sympa_conf();
}
## Set locale configuration
## Compatibility with version < 2.3.3
$main::options{'lang'} =~ s/\.cat$//
......
Supports Markdown
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