On Thu, Mar 4, 2021 at 8:33 PM Andrew Dunstan <and...@dunslane.net> wrote: > > > On 3/4/21 2:08 PM, Andres Freund wrote: > > [...] pgwin32_is_service() doesn't actually reliably detect if running as > > a service - it's a heuristic that also triggers when running postgres > > within a windows docker container (presumably because that itself is run > > from within a service?). > > > > > > ISTM that that's a problem, and is likely to become more of a problem > > going forward (assuming that docker on windows will become more > > popular). > > > > > > My opinion is that the whole attempt at guessing whether we are running > > as a service is a bad idea. This isn't the first time to be a problem, > > see e.g. [1]. > > > > Why don't we instead have pgwin32_doRegister() include a parameter that > > indicates we're running as a service and remove all the heuristics? > > > > I assume you mean a postmaster parameter, that would be set via pg_ctl? > Seems reasonable.
The problem with doing it at register time is that everybody who builds an installer for PostgreSQL will then have to do it in their own registration (I'm pretty sure most of them don't use pg_ctl register). The same thing in pgwin32_doRunAsService() might help with that. But then we'd have to figure out what to do if pg_ctl fails prior to reaching that point... There aren't that many such paths, but there are some. Just throwing out ideas without spending time thinking about it, maybe log to *both* in the case when we pick by it by autodetection? -- Magnus Hagander Me: https://www.hagander.net/ Work: https://www.redpill-linpro.com/