1

systemd unit file was created to control the start and stop of Postgres. It works just fine as expected if systemctl start or start command is used. But, if the machine is rebooted (systemctl reboot), then during its shutdown, the postgres process ALWAYS gets killed before ExecStop script is executed. By the time ExecStop script is executed, the process has been already killed and the script fails.

Here is the unit file:

[Unit]
Description=PostgresStartStop service
Requires=network.target
After=network.target
Before=shutdown.target reboot.target halt.target kexec.target 
DefaultDependencies=no

[Service]
Type=forking
RemainAfterExit=yes
ExecStart=/etc/rc.d/init.d/postgresStartStop start
ExecStop=/etc/rc.d/init.d/postgresStartStop stop
TimeoutSec=900
StandardOutput=inherit
PIDFile=/var/lib/pgsql/data/postmaster.pid

[Install]
WantedBy=multi-user.target 

I tried many different directives, but no avail.

  • I have seen Systemd send Sigterm AND SigHUP to services that don't have explicit unit files essentially at the same time that the unit files are being ingested. There is probably a race somewhere, but I don't have enough information to tell you anything certain. – Gregg Leventhal Aug 12 '18 at 1:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.