Re: Patch: Add launchd Support

From: "David E(dot) Wheeler" <david(at)justatheory(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Patch: Add launchd Support
Date: 2014-10-21 00:03:24
Message-ID: 679D67C7-F3D3-4EC4-8050-D813539E488D@justatheory.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Oct 20, 2014, at 4:36 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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 the former 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 what that means. We might be able to put something in LaunchEvents that gets it to fire when the network launches, but documentation is 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 less opaque, 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 rotation stuff, 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David E. Wheeler 2014-10-21 00:03:58 Re: Patch: Add launchd Support
Previous Message Jim Nasby 2014-10-20 23:58:34 Re: Patch: Add launchd Support