I've written a small patch for following TODO item:
«Add GUC variable to run a command on database
panic or smart/fast/immediate shutdown.»
It adds two GUC variables as:
enable_atexit_script_file
atexit_script_file
postmaster will run related script file with passing shutdown type
(like "smart", "fast" or "immediate") as parameter to script file
on database shutdown. (Sorry, I'm not so good on PostgreSQL internals,
thus couldn't handle "panic" situation at the moment.)
I know, it's not the perfect one but I'd be so apprecited to hear
suggestions for fixing lost/wrong parts of it.
Regards.
--
"We are the middle children of history, raised by television to believe
that someday we'll be millionaires and movie stars and rock stars, but
we won't. And we're just learning this fact," Tyler said. "So don't
fuck with us."