Re: Patch: Add launchd Support - Mailing list pgsql-hackers

From David E. Wheeler
Subject Re: Patch: Add launchd Support
Date
Msg-id 679D67C7-F3D3-4EC4-8050-D813539E488D@justatheory.com
Whole thread Raw
In response to Re: Patch: Add launchd Support  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Patch: Add launchd Support
Re: Patch: Add launchd Support
List pgsql-hackers
On Oct 20, 2014, at 4:36 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> (1) I'd vote for just removing the SystemStarter stuff: it complicates
> understanding what's happening, to no very good end.  We can easily
> check that the launchd way works back to whatever we think our oldest
> supported OS X release is.  (10.4.x according to the buildfarm, at least;
> and I think SystemStarter was deprecated even then ...)

Okay. Might have to use OnDemand instead of KeepAlive on 10.4. The former was deprecated in 10.5, but I’m not sure when
theformer was added. 

> (2) AFAICS, this .plist file doesn't do anything about launchd's habit of
> not waiting for the network to come up.  See my comments in today's thread
> in -general:
> http://www.postgresql.org/message-id/1239.1413823243@sss.pgh.pa.us

Ha! How funny you posted a call for a patch today. I didn’t see that, just needed to get it working today myself.

Anyway, I knew there was a reason I didn’t bother with this years ago: launchd does not support dependencies. From the
launchd.plist(5)

> DEPENDENCIES
>      Unlike many bootstrapping daemons, launchd has no explicit dependency model.
>      Interdependencies are expected to be solved through the use of IPC. It is
>      therefore in the best interest of a job developer who expects dependents to
>      define all of the sockets in the configuration file. This has the added ben-
>      efit of making it possible to start the job based on demand instead of imme-
>      diately.  launchd will continue to place as many restrictions on jobs that
>      do not conform to this model as possible.

This another reason not to use KeepAlive, I guess. OnDemand is supposed to fire up a job only when it’s needed. No idea
whatthat means. We might be able to put something in LaunchEvents that gets it to fire when the network launches, but
documentationis hella thin (and may only be supported on Yosemite, where there are a bunch of poorly-documented launchd
changes).

> (3) I don't think you want Disabled = true.

It’s the default. When you run `launchctl load -w` it overrides it to false in its database. I’m fine to have it be
lessopaque, though. 

> (4) I'm suspicious of all the -c arguments in the .plist file.  In general
> I'm not a fan of specifying GUCs on the postmaster command line; that
> makes it impossible to override their values via "normal" methods like
> postgresql.conf or ALTER SYSTEM.

Yeah, I am okay with removing those; they weren’t in the SystemStarter script. Was the only way to replicate the log
rotationstuff, but probably best not to do that in the start script, anyway. 

> (5) According to the launchd.plist man page, there are options for
> redirecting stdout and stderr to someplace useful.  It might be worth
> exercising those ...

Suggestions?

Best,

David



pgsql-hackers by date:

Previous
From: Jim Nasby
Date:
Subject: Re: Patch: Add launchd Support
Next
From: "David E. Wheeler"
Date:
Subject: Re: Patch: Add launchd Support