Re: Option on `postgres` CLI to shutdown when there are no more active connections?

From: Ron Johnson <ronljohnsonjr(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Option on `postgres` CLI to shutdown when there are no more active connections?
Date: 2025-10-12 02:56:31
Message-ID: CANzqJaBOWpoBDSNsxO=+zna1DEAqUNct5wm=4vQsOXiPwY7x=Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Oct 11, 2025 at 7:11 PM Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
wrote:

> On 10/8/25 12:39, David Barsky wrote:
> > Hiya folks,
> >
> > I'm a bit of a newcomer when it comes to PostgreSQL, so I apologize if
> > this is
> > the wrong mailing list. Anyways, my two questions:
> >
> > 1. Is there any interest in adding a command line option to the
> > `postgres` CLI
> > that shuts down the PostgreSQL instance once (and optionally cleans
> > up the
> > data directory) once all connections have disconnected?
>
> https://www.postgresql.org/docs/current/app-pg-ctl.html
>
> "
> stop mode shuts down the server that is running in the specified data
> directory. Three different shutdown methods can be selected with the -m
> option. “Smart” mode disallows new connections, then waits for all
> existing clients to disconnect. If the server is in hot standby,
> recovery and streaming replication will be terminated once all clients
> have disconnected. “Fast” mode (the default) does not wait for clients
> to disconnect. All active transactions are rolled back and clients are
> forcibly disconnected, then the server is shut down. “Immediate” mode
> will abort all server processes immediately, without a clean shutdown.
> This choice will lead to a crash-recovery cycle during the next server
> start.
> "
>

I think OP is looking for AUTO_CLOSE, like SQL Server (and Rdb/VMS before
it). Its only real utility is OP's use-case: a Windows desktop running
local testing.

We in the shell scripting daemon world don't think like that.

--
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2025-10-12 03:21:06 Re: Option on `postgres` CLI to shutdown when there are no more active connections?
Previous Message Greg Sabino Mullane 2025-10-12 01:44:34 Re: Index (primary key) corrupt?