Commit 9ac67cc5 authored by Christoph Berg's avatar Christoph Berg

Catch all pg_ctl output by redirecting it to /var/log/postgresql. (Closes: #830485)

parent 269b47e6
postgresql-common (179) UNRELEASED; urgency=medium
* Catch all pg_ctl output by redirecting it to /var/log/postgresql.
(Closes: #830485)
* Set default log_line_prefix to '%m [%p] %q%u@%d ' to match upstream
moving to '%m [%p] ' in PostgreSQL 10.
* Import new apt.postgresql.org key.
......
......@@ -6,7 +6,7 @@
#
# (C) 2005-2009 Martin Pitt <mpitt@debian.org>
# (C) 2009 Cyril Bouthors <cyril@bouthors.org>
# (C) 2013-2015 Christoph Berg <myon@debian.org>
# (C) 2013-2017 Christoph Berg <myon@debian.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -203,12 +203,24 @@ sub start {
if (fork) {
wait;
error "could not exec $pg_ctl @options: $!" if $?;
if ($?) {
my $exit = $? >> 8;
print STDERR "Error: $pg_ctl @options exited with status $exit: $!\n";
my $currlogsize = (stat $info{'logfile'})[7] if $info{'logfile'} && -r $info{'logfile'};
if ($currlogsize) {
open LOG, $info{'logfile'} or
error "Could not open log file " . $info{'logfile'};
seek LOG, $logsize, SEEK_SET;
print STDERR $_ while <LOG>;
}
exit $exit;
}
} else {
setsid or error "could not start session: $!";
# without this, you'll get zombies on startup
dup2(POSIX::open('/dev/null', POSIX::O_WRONLY), 1);
dup2(POSIX::open('/dev/null', POSIX::O_WRONLY), 2);
# without dup2, you'll get zombies on startup
my $output = $info{'logfile'} && -r $info{'logfile'} ? $info{'logfile'} : '/dev/null';
dup2(POSIX::open($output, POSIX::O_WRONLY | POSIX::O_APPEND | POSIX::O_CREAT), 1);
dup2(POSIX::open($output, POSIX::O_WRONLY | POSIX::O_APPEND | POSIX::O_CREAT), 2);
exec $pg_ctl @options or error "could not exec $pg_ctl @options: $!";
}
......
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