The documentation for docker stop command says that it sends SIGINT, and after configurable amount of time, SIGKILL.
According to PostgreSQL shutdown documentation, SIGINT is the gracest way to stop, waiting infinitely for all running sessions to terminate. SIGTERM will cause all sessions to terminate immediately, which can cause data lost.
Therefore I'd like to customize the docker stop process, by first sending SIGINT signal, then after a period of time of my choice send SIGTERM, and only if SIGTERM won't terminate the server withing given time, SIGKILL.
I don't want to issue SIGTERM at the begin, giving the chance to running transactions to terminate, but I don't want to SIGKILL server because some session was hanging...
Is it possible to configure docker stop process to intruduce 3rd step (SIGTERM)?