Re: Updated macOS start scripts

From: Mark Dilger <hornschnorter(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Updated macOS start scripts
Date: 2017-11-28 19:57:41
Message-ID: B55F452A-1579-4985-8D85-19FD50994399@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


> On Nov 28, 2017, at 11:17 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Mark Dilger <hornschnorter(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Brian Cloutier 2017-11-28 20:00:05 Re: Add PGDLLIMPORT lines to some variables
Previous Message Robert Haas 2017-11-28 19:55:50 Re: pgindent run?