From 462b54dee2411957794f082184337db8fc6ff141 Mon Sep 17 00:00:00 2001 From: Marcos de Oliveira Date: Thu, 20 Jul 2023 17:21:09 -0300 Subject: [PATCH] BUG/MINOR: server-state: Avoid warning on 'file not found' On a clean installation, users might want to use server-state-file and the recommended zero-warning option. This caused a problem if server-state-file was not found, as a warning was emited, causing startup to fail. This will allow users to specify nonexistent server-state-file at first, and dump states to the file later. Fixes #2190 CF: Technically speaking, this patch can be backported to all stable versions. But it is better to do so to 2.8 only for now. --- src/server_state.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/server_state.c b/src/server_state.c index 9636b9f6d..ebdcf3c69 100644 --- a/src/server_state.c +++ b/src/server_state.c @@ -799,7 +799,10 @@ void apply_server_state(void) errno = 0; f = fopen(file, "r"); if (!f) { - ha_warning("config: Can't open global server state file '%s': %s\n", file, strerror(errno)); + if (errno == ENOENT) + ha_notice("config: Can't open global server state file '%s': %s\n", file, strerror(errno)); + else + ha_warning("config: Can't open global server state file '%s': %s\n", file, strerror(errno)); goto no_globalfile; } @@ -871,8 +874,12 @@ void apply_server_state(void) errno = 0; f = fopen(file, "r"); if (!f) { - ha_warning("Proxy '%s': Can't open server state file '%s': %s.\n", - curproxy->id, file, strerror(errno)); + if (errno == ENOENT) + ha_notice("Proxy '%s': Can't open server state file '%s': %s.\n", + curproxy->id, file, strerror(errno)); + else + ha_warning("Proxy '%s': Can't open server state file '%s': %s.\n", + curproxy->id, file, strerror(errno)); continue; /* next proxy */ }