Re: Updated macOS start scripts - Mailing list pgsql-hackers

From Mark Dilger
Subject Re: Updated macOS start scripts
Date
Msg-id B55F452A-1579-4985-8D85-19FD50994399@gmail.com
Whole thread Raw
In response to Re: Updated macOS start scripts  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Updated macOS start scripts  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
> On Nov 28, 2017, at 11:17 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Mark Dilger <hornschnorter@gmail.com> writes:
>> Upon further review, I have noticed that `pg_ctl stop` does not work once
>> the org.postgresql.postgres service has been started.  I was trying to stop,
>> reinstall and re-initdb and restart postgres and this service was a pita.  I had
>> to go back to your osx.patch to remind myself what I had done and only then
>> could I stop the service and continue my work.
>
>> Is there any way this patch could be improved to work nicely with pg_ctl?  It
>> seems that `pg_ctl stop` indeed stops the postgres process, but the system
>> launches a new one so quickly that pg_ctl thinks the service has not stopped,
>> and it just waits forever (or until it times out, depending on your settings).
>
> Hmm.  Maybe we should have the plist file set KeepAlive to false not true?
> This would mean you'd need manual action to restart a failed postmaster,
> but that probably comes with the territory --- I do not see how we'd
> teach launchd the difference between a "failed" postmaster and a manually
> shut down one.

Setting KeepAlive to false does more than you probably want it to; it also
causes the service not to start on boot nor on load.  After setting this to
false, I tried a reboot and the service was not started.

>
> I think the normal way to stop/restart a launchd service is to use
> "launchctl unload/load" ... we'd need to see how that interacts with
> using pg_ctl.  Some documentation might be needed in any case.

"launchctl load" won't do it.  You need to use
sudo launchctl start org.postgresql.postgres

and
sudo launchctl stop org.postgresql.postgres

to get the behavior you are looking for.  Note that start/stop take the name of
the service, and load/unload take the name of the file.  They're different, though
related.

I think anybody who uses launchctl on mac should already know what it does.
I'm not too concerned about that.  I think the hazard is that somebody who does
not normally use launchctl on mac, but who reads through the postgres
contrib/start-scripts directory, will follow the instructions in this patch and
form a false expectation about what will result from configuring their mac laptop
this way.

Of course, you could make pg_ctl know how to interact with launchctl if you
like.  That seems quite hard, and I am not volunteering....

mark



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: pgindent run?
Next
From: Brian Cloutier
Date:
Subject: Re: Add PGDLLIMPORT lines to some variables