Commit a0db2528 authored by Martin Pitt's avatar Martin Pitt

pg_ctlcluster: Check if autovacuum daemon is really running, cat log if not

parent ecd00ee6
......@@ -2,9 +2,7 @@ postgresql TODO
===============
Bugs:
- pg_ctlcluster: Check if autovacuum daemon is really running, cat log
if not.
Important features:
- add infrastructure to support running scripts/SQL commands on all
databases on upgrading (like necessary for the two recent CANs)
......
......@@ -5,8 +5,10 @@ postgresql-common (14) experimental; urgency=low
* Added test 110_invalid_conf: test checking of invalid configurations.
* Ship test suite in /usr/share/postgresql-common.
* pg_ctlcluster: Fix logging of autovacuum daemon.
* pg_ctlcluster: Check if autovacuum daemon is really running, exit with an
error and print log if not.
-- Martin Pitt <mpitt@debian.org> Sun, 5 Jun 2005 10:49:47 +0200
-- Martin Pitt <mpitt@debian.org> Sun, 5 Jun 2005 11:19:08 +0200
postgresql-common (13) experimental; urgency=low
......
......@@ -8,7 +8,7 @@
use lib '/usr/share/postgresql-common';
use Getopt::Long;
use POSIX qw/setsid setlocale LC_ALL/;
use POSIX qw/setsid setlocale LC_ALL :sys_wait_h/;
use PgCommon;
use Fcntl 'SEEK_SET';
......@@ -57,13 +57,31 @@ sub autovacuum_start {
}
}
if (!($pid = fork())) {
# remember current size of the log
my $logsize = 0;
$logsize = (stat $info{'avac_logfile'})[7] if -r $info{'avac_logfile'};
if (!($pid = fork)) {
setsid or die "setsid failed(): $!";
close $_ for(STDOUT, STDIN, STDERR);
setsid;
chdir '/';
exec $pg_autovacuum, @options;
exit -1;
} else {
# wait a bit and check whether the daemon really started
select (undef, undef, undef, 0.5);
# clean up process if it exited
waitpid($pid, WNOHANG);
unless (kill 0, $pid) {
print STDERR "The PostgreSQL autovacuum daemon failed to start. Please check the log output:\n";
open LOG, $info{'avac_logfile'} or
error "Could not open log file " . $info{'avac_logfile'};
seek LOG, $logsize, SEEK_SET;
print STDERR $_ while <LOG>;
exit 1;
}
# write PID file
if(open my $AVAC_PID, '>', $info{'pgdata'}.'/autovacuum.pid') {
print $AVAC_PID "$pid\n";
close $AVAC_PID;
......
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