Subject: | Postmaster startup indication fail |
_try_start() opens postgres.log and waits for "is ready to accept connections" to indicate that postgresql is up and ready.
This mechanism does not work with current postgresql versions:
1) Postgresql switches logfile to s/th inside data/pg_log/postgresql-{Weekday}.log
2) Postgresql installation is localized and so are the log messages (at least with fedora)
Proposal: Instead of logfile tailing/scanning, try to connect.
See attached patch.
Btw.: Test::Postgresql, which is newer, has the same problem: https://metacpan.org/source/TJC/Test-PostgreSQL-0.10/lib/Test/PostgreSQL.pm#L163
Greets,
Markus
Subject: | patch-Test-postgresl-localized-log.diff |
--- orig/postgresql.pm
+++ postgresql.pm 2014-06-16 09:39:17.990283317 +0200
@@ -160,16 +160,12 @@
close $logfh;
# wait until server becomes ready (or dies)
for (my $i = 0; $i < 100; $i++) {
- open $logfh, '<', $self->base_dir . '/postgres.log'
- or die 'failed to open log file:' . $self->base_dir
- . "/postgres.log:$!";
- my $lines = do { join '', <$logfh> };
- close $logfh;
- last
- if $lines =~ /is ready to accept connections/;
+ if ( DBI->connect($self->dsn(dbname => 'template1',port=>$port), '', '', {}) ) {
+ last;
+ }
if (waitpid($pid, WNOHANG) > 0) {
# failed
- return $lines;
+ return 1;
}
sleep 1;
}