14.10.2025 23:49:21 David Barsky <[email protected]>:

> 1. If that script is cancelled or interrupted for any reason, it’s possible 
> that
>    `pg_ctl stop` won't be called and I'd have a leaked process.

As others stated, some shells have the trapping functionality.

> I could mitigate
>    this by calling `pg_ctl stop` at the *start* of the script, but that adds a
>    bit of latency I'd prefer to avoid.

I wonder what the reason is to avoid that latency in the script. Spinning down 
the DB will take time anyway.

Would it be possible to make a procedure run at the start of the DB, like a 
daemon, checking for the last connection to quit if there has been one, and to 
shutdown the DB in an ordered manner?

Just my two Rappen


Reply via email to