Is there any simple way how to set up systemd so it runs a script or a unit when system boots after a crash ? And possibly have other units wait on its completion? I suppose I could write a unit that will set some sort of flag on shutdown and check that on boot but I was wondering whether systemd does not have something like that already implemented...
I ran into funny problem with postgresql not starting after crash because of PID files mismatch and I would like to delete the PID files before the postgresql services starts.
I have two instances of postgresql and as the boot process is cca same every time the server boots, the postmasters gets same PIDs every time - but in undefined order. And if there are stale PID files, sometimes one of the servers starts (clears its PID file) but the other sees its stale PID file and even postmaster process with that PID (the other instance) and it refuses to start...
Details: Fedora 20, systemd-208
Footnote: I know that it would be better to avoid the crashes but in this case its more important that the server runs than its data (I can replicate them from base server)