Re: win32 service proposal

From: "Magnus Hagander" <mha(at)sollentuna(dot)net>
To: "Darko Prenosil" <Darko(dot)Prenosil(at)finteh(dot)hr>, "Claudio Natoli" <claudio(dot)natoli(at)memetrics(dot)com>, "PostgreSQL-patches" <pgsql-patches(at)postgresql(dot)org>
Subject: Re: win32 service proposal
Date: 2004-05-04 11:47:39
Message-ID: 6BCB9D8A16AC4241919521715F4D8BCE34B910@algol.sollentuna.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches


> I played a bit with that code. According to Microsoft samples
> for service managers, errors and events should be logged to
> eventlog. so I added a function (almost copy of sample
> service code), it's a messy, but it was enough to see what is
> happening with the service.

Consider using ereport() if it's available at that time - then it'll go
to the correct place. Otherwise, look at the code in
backend/utils/error/elog.c, and the write_eventlog() function. Might
want to make that one non-static and call that one. That way we're sure
the messages end up in the same category in the eventlog.

> 1.
> I'll try to describe what happens in few steps:
> a.) register service using:
> C:\msys\1.0\local\pgsql\bin\postmaster /register postgres -D
> C:/msys/1.0/local/pgsql/data
> b.) start service manager
> c.) start the service (it starts fine)
> d.) unregister service using: C:\msys\1.0\local\pgsql\bin\postmaster
> /unregister postgres
>
> After that postgres "status type" in service manager changes
> to "disabled", and I'm unable to do anything with service.

Yes, this is normal if you unregister a service *while it is running*.

> The only way is restarting NT. It seems that this happens no
> matter service is started or stopped, enough is that service
> manager is started and cursor is positioned on "postgres"
> service. Is this some kind of Win bug ?

It shuold not happen when it's not started. In that case, it should be
enough to restart the services MMC snapin. Or if you're on NT4, you need
to restart the control panel (uh, maybe even logout/in). But you
shouldn't need a reboot.

> 2.
> When invalid parameter for postmaster is set, for example: -D
> C:/msys/1.0/local/pgsql/dataX, CreateProcess returns true,
> but postmaster exit with FATAL. How can we detect this
> situation and send the postmaster error string into log ?

postgresql.conf, set log_destination to eventlog. That should put it in
a place you can see it.

//Magnus

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2004-05-04 12:21:58 Re: Run-as-admin warning for win32
Previous Message Magnus Hagander 2004-05-04 11:01:27 Re: Run-as-admin warning for win32