The recommended way to shutdown
postgres is to send a signal representing the different shutdown modes (fast, smart, immediate) or using init managers (
systemd, etc.) or their equivalent on non-Linux OS. In a containerized environment it's sometimes more convenient to gain access through
docker exec and thus more convenient to stop the server through
psql. Is there a way to do that (given that the privileges have been granted)?
The solution can be hacky since this will mostly be used to stop a
postgres to delete a PostgreSQL data directory in a development environment.