mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-02-05 19:09:58 +08:00
Fix some minor issues with the new Win32 service code for autovacuum,
and add documentation. Dave Page
This commit is contained in:
parent
b04e70b11e
commit
92244e8e54
@ -55,6 +55,15 @@ postmasters on a particular host, you will need multiple pg_autovacuum
|
|||||||
instances, and they have no way, at present, to coordinate between one
|
instances, and they have no way, at present, to coordinate between one
|
||||||
another to ensure that they do not concurrently vacuum big tables.
|
another to ensure that they do not concurrently vacuum big tables.
|
||||||
|
|
||||||
|
When installed as a service under Windows, there is currently no way to
|
||||||
|
know the name of the PostgreSQL server service (if there even is one)
|
||||||
|
so it is not possible to specify a startup dependency. It is therefore
|
||||||
|
possible for pg_autovacuum to start before the server.
|
||||||
|
|
||||||
|
When installed as a service under Windows, if the -P option is used to
|
||||||
|
specify the connection password, this option (and the password) is
|
||||||
|
stored in plain text in the registry.
|
||||||
|
|
||||||
TODO:
|
TODO:
|
||||||
-----
|
-----
|
||||||
|
|
||||||
@ -117,7 +126,9 @@ pg_autovacuum has the following optional arguments:
|
|||||||
-L log file: Name of file to which output is submitted, otherwise STDERR
|
-L log file: Name of file to which output is submitted, otherwise STDERR
|
||||||
-U username: Username pg_autovacuum will use to connect with, if not
|
-U username: Username pg_autovacuum will use to connect with, if not
|
||||||
specified the current username is used.
|
specified the current username is used.
|
||||||
-P password: Password pg_autovacuum will use to connect with.
|
-P password: Password pg_autovacuum will use to connect with. *WARNING*
|
||||||
|
When installed as a Windows Service, this option will be stored in plain
|
||||||
|
text in the registry.
|
||||||
-H host: host name or IP to connect to.
|
-H host: host name or IP to connect to.
|
||||||
-p port: port used for connection.
|
-p port: port used for connection.
|
||||||
-h help: list of command line options.
|
-h help: list of command line options.
|
||||||
@ -133,6 +144,19 @@ the time of writing they are:
|
|||||||
-s 300 (5 minutes)
|
-s 300 (5 minutes)
|
||||||
-S 2
|
-S 2
|
||||||
|
|
||||||
|
The following arguments are used on Windows only:
|
||||||
|
|
||||||
|
-I Install the executable as a Windows service. Other appropriate command
|
||||||
|
line options will be stored in the registry and passed to the service
|
||||||
|
at startup. *WARNING* This includes the connection password which will
|
||||||
|
be stored in plain text.
|
||||||
|
|
||||||
|
-N service user: Name of the Windows user account under which the service
|
||||||
|
will run.
|
||||||
|
|
||||||
|
-W service password: The password for the service account.
|
||||||
|
|
||||||
|
-R Uninstall pg_autovacuum as a service.
|
||||||
|
|
||||||
Vacuum and Analyze:
|
Vacuum and Analyze:
|
||||||
-------------------
|
-------------------
|
||||||
|
@ -25,12 +25,8 @@ log_entry(const char *logentry, int level)
|
|||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Note: Under Windows we dump the log entries to the normal
|
* Note: Under Windows we dump the log entries to the normal
|
||||||
* stderr/logfile
|
* stderr/logfile as well, otherwise it can be a pain to debug
|
||||||
*/
|
* service install failures etc.
|
||||||
|
|
||||||
/*
|
|
||||||
* as well, otherwise it can be a pain to debug service install
|
|
||||||
* failures etc.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
time_t curtime;
|
time_t curtime;
|
||||||
@ -117,7 +113,7 @@ log_entry(const char *logentry, int level)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReportEvent(evtHandle, elevel, 0, 1, NULL, 1, 0, &logentry, NULL);
|
ReportEvent(evtHandle, elevel, 0, 0, NULL, 1, 0, &logentry, NULL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1219,7 +1215,7 @@ InstallService()
|
|||||||
if (args->user)
|
if (args->user)
|
||||||
sprintf(szCommand, "%s -U %s", szCommand, args->user);
|
sprintf(szCommand, "%s -U %s", szCommand, args->user);
|
||||||
if (args->password)
|
if (args->password)
|
||||||
sprintf(szCommand, "%s -p %s", szCommand, args->password);
|
sprintf(szCommand, "%s -P %s", szCommand, args->password);
|
||||||
if (args->logfile)
|
if (args->logfile)
|
||||||
sprintf(szCommand, "%s -L %s", szCommand, args->logfile);
|
sprintf(szCommand, "%s -L %s", szCommand, args->logfile);
|
||||||
if (args->sleep_base_value != (int) SLEEPBASEVALUE)
|
if (args->sleep_base_value != (int) SLEEPBASEVALUE)
|
||||||
@ -1249,21 +1245,12 @@ InstallService()
|
|||||||
if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hk, NULL))
|
if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hk, NULL))
|
||||||
return -5;
|
return -5;
|
||||||
|
|
||||||
/* TODO Create an actual message file! */
|
/* TODO Try to find pgevent.dll, rather than hope it's in the path. ! */
|
||||||
/* Message count */
|
/* Message DLL */
|
||||||
sprintf(szMsgDLL, "pgmessages.dll");
|
sprintf(szMsgDLL, "pgevent.dll");
|
||||||
if (RegSetValueEx(hk, "EventMessageFile", 0, REG_EXPAND_SZ, (LPBYTE) szMsgDLL, (DWORD) strlen(szMsgDLL) + 1))
|
if (RegSetValueEx(hk, "EventMessageFile", 0, REG_EXPAND_SZ, (LPBYTE) szMsgDLL, (DWORD) strlen(szMsgDLL) + 1))
|
||||||
return -6;
|
return -6;
|
||||||
|
|
||||||
/* Category message file */
|
|
||||||
if (RegSetValueEx(hk, "CategoryMessageFile", 0, REG_EXPAND_SZ, (LPBYTE) szMsgDLL, (DWORD) strlen(szMsgDLL) + 1))
|
|
||||||
return -7;
|
|
||||||
|
|
||||||
/* Category message count */
|
|
||||||
dwData = 0;
|
|
||||||
if (RegSetValueEx(hk, "CategoryCount", 0, REG_DWORD, (LPBYTE) & dwData, sizeof(DWORD)))
|
|
||||||
return -8;
|
|
||||||
|
|
||||||
/* Set the event types supported */
|
/* Set the event types supported */
|
||||||
dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE | EVENTLOG_SUCCESS;
|
dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE | EVENTLOG_SUCCESS;
|
||||||
if (RegSetValueEx(hk, "TypesSupported", 0, REG_DWORD, (LPBYTE) & dwData, sizeof(DWORD)))
|
if (RegSetValueEx(hk, "TypesSupported", 0, REG_DWORD, (LPBYTE) & dwData, sizeof(DWORD)))
|
||||||
|
Loading…
Reference in New Issue
Block a user