[Unit]
Description=PostgreSQL Cluster %i
AssertPathExists=/etc/postgresql/%I/postgresql.conf
RequiresMountsFor=/etc/postgresql/%I /var/lib/postgresql/%I
PartOf=postgresql.service
ReloadPropagatedFrom=postgresql.service
Before=postgresql.service
# stop server before networking goes down on shutdown
After=network.target
[Service]
Type=forking
# -: ignore startup failure (recovery might take arbitrarily long)
# the actual pg_ctl timeout is configured in pg_ctl.conf
ExecStart=-/usr/bin/pg_ctlcluster --skip-systemctl-redirect %i start
# 0 is the same as infinity, but "infinity" needs systemd 229
TimeoutStartSec=0
ExecStop=/usr/bin/pg_ctlcluster --skip-systemctl-redirect -m fast %i stop
TimeoutStopSec=1h
ExecReload=/usr/bin/pg_ctlcluster --skip-systemctl-redirect %i reload
PIDFile=/run/postgresql/%i.pid
SyslogIdentifier=postgresql@%i
# prevent OOM killer from choosing the postmaster (individual backends will
# reset the score to 0)
OOMScoreAdjust=-900
# restarting automatically will prevent "pg_ctlcluster ... stop" from working,
# so we disable it here. Also, the postmaster will restart by itself on most
# problems anyway, so it is questionable if one wants to enable external
# automatic restarts.
#Restart=on-failure
# (This should make pg_ctlcluster stop work, but doesn't:)
#RestartPreventExitStatus=SIGINT SIGTERM
[Install]
WantedBy=multi-user.target
# Check whether a postgres server is running at the specified port.
# Arguments: <version> <cluster> <port>
sub cluster_port_running {
die "port_running: invalid port $_[2]" if $_[2] !~ /\d+/;
my $socketdir = get_cluster_socketdir $_[0], $_[1];
my $socketpath = "$socketdir/.s.PGSQL.$_[2]";
return 0 unless -S $socketpath;
socket(SRV, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
my $running = connect(SRV, sockaddr_un($socketpath));
close SRV;
return $running ? 1 : 0;
}
Cette fonction tente d'ouvrir une connexion et si ça marche, la ferme immédiatement, le but étant juste de savoir si ça répond ou pas. Que postgres logge l'erreur "paquet de démarrage incomplet" est un effet de bord de ce test.
]]>Du coup, je n'ai pas bien compris votre dernier message. Problème résolu ou pas ?
]]>Je ne m'y connais pas mais cela ressemble à ce cas là : https://forums.postgresql.fr/viewtopic.php?id=5500
Un "test de vie" (sorte de ping) qui ne ferme pas (ou mal) sa connexion.
Est-ce que cette ligne se répète dans le temps dans les logs ensuite ?
]]>