Обсуждение: pg_autovacuum Win32 service patch

Поиск
Список
Период
Сортировка

pg_autovacuum Win32 service patch

От
"Dave Page"
Дата:
Hi all,

The attached patch is the result of a brief session hacking
pg_autovacuum to run as a native Win32 application or service. It needs
more work before it's ready for production but I thought it best to get
some comments before going any further (which incidently, I cannot
guarantee I'll have time to do as my free time is somewhat unpredictable
right now).

Under Win32 there are now 2 new command line options:

-I - Install as a service
-R - Remove service

Both fairly self explanatory. The daemonize option is removed currently
(under Win32) due to lack of fork() on 'doze. There are a few issues:

1) Logging is now done to the event log. These are 2 problems:

- The startup messages are plentiful and soon start to fill the event
log.
- All messages are currently logged as 'Informational'. With addition of
error levels to the code this can be improved.
- Without a message library the events look terrible (I imagine the same
applies to the server). Eg.

Event Type:    None
Event Source:    PostgreSQL Auto Vacuum Daemon
Event Category:    None
Event ID:    0
Date:        06/05/2004
Time:        14:05:39
User:        N/A
Computer:    PC30
Description:
The description for Event ID ( 0 ) in Source ( PostgreSQL Auto Vacuum
Daemon ) cannot be found. The local computer may not have the necessary
registry information or message DLL files to display messages from a
remote computer. You may be able to use the /AUXSOURCE= flag to retrieve
this description; see Help and Support for details. The following
information is part of the event: added table:
dave."pg_catalog"."pg_description".

2) There is no way I can find to setup startup parameters for a service
without manually writing them to the appropriate key in the registry.
This raises the question of how best to take a config when run as a
service - would a config file be appropriate, or do we just write the
options specified when the service is installed to the registry the hard
way? There is an obvious password issue to consider.

Comments/criticisms appreciated :-)

Regards, Dave

Вложения

Re: pg_autovacuum Win32 service patch

От
"Magnus Hagander"
Дата:
Hi!

A few quick comments:
1a) Please don't use such a long name for event source. It's so hard to
browse in the event viewer :-)

1b) Yes, the same problem with the main code. I think we'll want to
create a specific messagel ibrary that just maps all events to "%1" to
show the string. This one could be shared between any processesw that
need it. This should probably go up on the win32 TODO list - Claudio or
Bruce?

1c) Yes, errorlevels = nice. Most (I would think at least) management
tools that crawl eventlogs over all your servers to tell you about
things that are wrong will look for warning/error messages only...

2) I'll go there again - there *needs* to be a way to make it run as !=
local system. If we make the main server *forcibly* refuse Local System,
then we should do the same here. If we go to warning, we should do that
here. But there needs to be an easy way to install it as != admin.

3) For the main service, I think the decision was to put them in the
service startup commandlien in the registry. We should probably stick to
the same method with this one.



A thought - are there more processes that would need this? Is there any
point to putting some of the service code in a library (pgport, even?)
to be shared between processes, so we don't have to reinvent the wheel
over and over again?


//Magnus


> -----Original Message-----
> From: Dave Page [mailto:dpage@vale-housing.co.uk]
> Sent: Thursday, May 06, 2004 3:38 PM
> To: pgsql-hackers-win32@postgresql.org
> Subject: [pgsql-hackers-win32] pg_autovacuum Win32 service patch
>
> Hi all,
>
> The attached patch is the result of a brief session hacking
> pg_autovacuum to run as a native Win32 application or
> service. It needs more work before it's ready for production
> but I thought it best to get some comments before going any
> further (which incidently, I cannot guarantee I'll have time
> to do as my free time is somewhat unpredictable right now).
>
> Under Win32 there are now 2 new command line options:
>
> -I - Install as a service
> -R - Remove service
>
> Both fairly self explanatory. The daemonize option is removed
> currently (under Win32) due to lack of fork() on 'doze. There
> are a few issues:
>
> 1) Logging is now done to the event log. These are 2 problems:
>
> - The startup messages are plentiful and soon start to fill
> the event log.
> - All messages are currently logged as 'Informational'. With
> addition of error levels to the code this can be improved.
> - Without a message library the events look terrible (I
> imagine the same applies to the server). Eg.
>
> Event Type:    None
> Event Source:    PostgreSQL Auto Vacuum Daemon
> Event Category:    None
> Event ID:    0
> Date:        06/05/2004
> Time:        14:05:39
> User:        N/A
> Computer:    PC30
> Description:
> The description for Event ID ( 0 ) in Source ( PostgreSQL
> Auto Vacuum Daemon ) cannot be found. The local computer may
> not have the necessary registry information or message DLL
> files to display messages from a remote computer. You may be
> able to use the /AUXSOURCE= flag to retrieve this
> description; see Help and Support for details. The following
> information is part of the event: added table:
> dave."pg_catalog"."pg_description".
>
> 2) There is no way I can find to setup startup parameters for
> a service without manually writing them to the appropriate
> key in the registry.
> This raises the question of how best to take a config when
> run as a service - would a config file be appropriate, or do
> we just write the options specified when the service is
> installed to the registry the hard way? There is an obvious
> password issue to consider.
>
> Comments/criticisms appreciated :-)
>
> Regards, Dave
>
>