[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Add service recovery options for QGA on windows
From: |
yshxxsjt715 |
Subject: |
[PATCH] Add service recovery options for QGA on windows |
Date: |
Mon, 15 Nov 2021 10:21:22 +0800 |
From: shenjiatong <yshxxsjt715@gmail.com>
Add default recovery options for QGA on windows. Previously, QGA
on windows will not try to restart service if it is down. This PS
add some default options for the first, second and other failures,
with an interval of 1min. Failure counter will reset after 1 day.
Signed-off-by: shenjiatong <yshxxsjt715@gmail.com>
---
qga/service-win32.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/qga/service-win32.c b/qga/service-win32.c
index fd434e3f49..0fc93d38c3 100644
--- a/qga/service-win32.c
+++ b/qga/service-win32.c
@@ -105,6 +105,18 @@ int ga_install_service(const char *path, const char
*logfile,
GString *esc;
GString *cmdline;
SERVICE_DESCRIPTION desc = { (char *)QGA_SERVICE_DESCRIPTION };
+ SC_ACTION sa[] = {
+ { SC_ACTION_RESTART, 60000},
+ { SC_ACTION_RESTART, 60000},
+ { SC_ACTION_RESTART, 60000}
+ };
+ SERVICE_FAILURE_ACTIONS sfa = {
+ 864000, // in seconds,
+ NULL,
+ NULL,
+ sizeof(sa) / sizeof(*sa),
+ sa
+ };
if (GetModuleFileName(NULL, module_fname, MAX_PATH) == 0) {
printf_win_error("No full path to service's executable");
@@ -146,6 +158,7 @@ int ga_install_service(const char *path, const char
*logfile,
}
ChangeServiceConfig2(service, SERVICE_CONFIG_DESCRIPTION, &desc);
+ ChangeServiceConfig2(service, SERVICE_CONFIG_FAILURE_ACTIONS, &sfa);
fprintf(stderr, "Service was installed successfully.\n");
ret = EXIT_SUCCESS;
CloseServiceHandle(service);
--
2.25.1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] Add service recovery options for QGA on windows,
yshxxsjt715 <=