supervise-daemon: only log debug logs when verbose mode is active

This commit is contained in:
William Hubbs 2020-09-25 16:33:32 -05:00
parent fbec1eed51
commit 2355f1a3f2

View File

@ -148,6 +148,7 @@ static char *fifopath = NULL;
static int fifo_fd = 0; static int fifo_fd = 0;
static char *pidfile = NULL; static char *pidfile = NULL;
static char *svcname = NULL; static char *svcname = NULL;
static bool verbose = false;
extern char **environ; extern char **environ;
@ -569,7 +570,8 @@ static void supervisor(char *exec, char **argv)
buf[count] = 0; buf[count] = 0;
if (count == 0) if (count == 0)
continue; continue;
syslog(LOG_DEBUG, "Received %s from fifo", buf); if (verbose)
syslog(LOG_DEBUG, "Received %s from fifo", buf);
if (strncasecmp(buf, "sig", 3) == 0) { if (strncasecmp(buf, "sig", 3) == 0) {
if ((sscanf(buf, "%s %d", cmd, &sig_send) == 2) if ((sscanf(buf, "%s %d", cmd, &sig_send) == 2)
&& (sig_send >= 0 && sig_send < NSIG)) { && (sig_send >= 0 && sig_send < NSIG)) {
@ -585,7 +587,8 @@ static void supervisor(char *exec, char **argv)
if (do_healthcheck) { if (do_healthcheck) {
do_healthcheck = 0; do_healthcheck = 0;
alarm(0); alarm(0);
syslog(LOG_DEBUG, "running health check for %s", svcname); if (verbose)
syslog(LOG_DEBUG, "running health check for %s", svcname);
health_pid = exec_command("healthcheck"); health_pid = exec_command("healthcheck");
health_status = rc_waitpid(health_pid); health_status = rc_waitpid(health_pid);
if (WIFEXITED(health_status) && WEXITSTATUS(health_status) == 0) if (WIFEXITED(health_status) && WEXITSTATUS(health_status) == 0)
@ -904,6 +907,7 @@ int main(int argc, char **argv)
case_RC_COMMON_GETOPT case_RC_COMMON_GETOPT
} }
verbose = rc_yesno(getenv ("EINFO_VERBOSE"));
endpwent(); endpwent();
argc -= optind; argc -= optind;
argv += optind; argv += optind;