refactor: Improve Windows daemon failure backoff for faster client restarts on first fail

This commit is contained in:
Nick Bolton 2025-02-19 13:32:56 +00:00
parent 16c57d7960
commit e808eed413

View file

@ -198,10 +198,12 @@ void MSWindowsWatchdog::mainLoop(void *)
continue; continue;
} }
if (m_processFailures != 0) { if (m_processFailures > 1) {
// increasing backoff period, maximum of 10 seconds. // increasing backoff period, maximum of 10 seconds.
int timeout = (m_processFailures * 2) < 10 ? (m_processFailures * 2) : 10; // only start sleeping at 1 second to avoid unnecessary delay when the process stops
LOG((CLOG_WARN "backing off, wait=%ds, failures=%d", timeout, m_processFailures)); // for the first failure (i.e. when the process just stopped running).
int timeout = m_processFailures < 10 ? m_processFailures : 10;
LOG_WARN("backing off, wait=%ds, failures=%d", timeout, m_processFailures);
ARCH->sleep(timeout); ARCH->sleep(timeout);
} }
@ -428,7 +430,7 @@ void MSWindowsWatchdog::outputLoop(void *)
void MSWindowsWatchdog::shutdownExistingProcesses() void MSWindowsWatchdog::shutdownExistingProcesses()
{ {
LOG_INFO("deamon shutting down existing processes"); LOG_INFO("daemon shutting down existing processes");
if (m_process != nullptr) { if (m_process != nullptr) {
m_process->shutdown(m_ipcServer); m_process->shutdown(m_ipcServer);