diff --git a/sapi/fpm/fpm/fpm_conf.c b/sapi/fpm/fpm/fpm_conf.c index 42f75a475d..862c6019c2 100644 --- a/sapi/fpm/fpm/fpm_conf.c +++ b/sapi/fpm/fpm/fpm_conf.c @@ -138,6 +138,7 @@ static struct ini_value_parser_s ini_fpm_pool_options[] = { { "pm.status_listen", &fpm_conf_set_string, WPO(pm_status_listen) }, { "ping.path", &fpm_conf_set_string, WPO(ping_path) }, { "ping.response", &fpm_conf_set_string, WPO(ping_response) }, + { "ping.dontlog", &fpm_conf_set_boolean, WPO(ping_dontlog) }, { "access.log", &fpm_conf_set_string, WPO(access_log) }, { "access.format", &fpm_conf_set_string, WPO(access_format) }, { "slowlog", &fpm_conf_set_string, WPO(slowlog) }, @@ -615,6 +616,7 @@ static void *fpm_worker_pool_config_alloc() /* {{{ */ wp->config->process_dumpable = 0; wp->config->clear_env = 1; wp->config->decorate_workers_output = 1; + wp->config->ping_dontlog = 1; /* don't log GET /ping */ if (!fpm_worker_all_pools) { fpm_worker_all_pools = wp; @@ -1724,6 +1726,7 @@ static void fpm_conf_dump() /* {{{ */ zlog(ZLOG_NOTICE, "\tpm.status_listen = %s", STR2STR(wp->config->pm_status_listen)); zlog(ZLOG_NOTICE, "\tping.path = %s", STR2STR(wp->config->ping_path)); zlog(ZLOG_NOTICE, "\tping.response = %s", STR2STR(wp->config->ping_response)); + zlog(ZLOG_NOTICE, "\tping.dontlog = %s", BOOL2STR(wp->config->ping_dontlog)); zlog(ZLOG_NOTICE, "\taccess.log = %s", STR2STR(wp->config->access_log)); zlog(ZLOG_NOTICE, "\taccess.format = %s", STR2STR(wp->config->access_format)); zlog(ZLOG_NOTICE, "\tslowlog = %s", STR2STR(wp->config->slowlog)); diff --git a/sapi/fpm/fpm/fpm_conf.h b/sapi/fpm/fpm/fpm_conf.h index cd71bb53fd..c5a93a1053 100644 --- a/sapi/fpm/fpm/fpm_conf.h +++ b/sapi/fpm/fpm/fpm_conf.h @@ -76,6 +76,7 @@ struct fpm_worker_pool_config_s { char *pm_status_listen; char *ping_path; char *ping_response; + int ping_dontlog; char *access_log; char *access_format; char *slowlog; diff --git a/sapi/fpm/fpm/fpm_log.c b/sapi/fpm/fpm/fpm_log.c index 6f1e517a9f..152215601b 100644 --- a/sapi/fpm/fpm/fpm_log.c +++ b/sapi/fpm/fpm/fpm_log.c @@ -27,6 +27,8 @@ static char *fpm_log_format = NULL; static int fpm_log_fd = -1; +static char *fpm_ping_path = NULL; +static int fpm_ping_dontlog = -1; int fpm_log_open(int reopen) /* {{{ */ { @@ -83,6 +85,13 @@ int fpm_log_init_child(struct fpm_worker_pool_s *wp) /* {{{ */ fpm_log_fd = wp->log_fd; } + if (wp->config->ping_path && *wp->config->ping_path) { + fpm_ping_path = strdup(wp->config->ping_path); + } + + if (fpm_ping_dontlog == -1) { + fpm_ping_dontlog = wp->config->ping_dontlog; + } for (wp = fpm_worker_all_pools; wp; wp = wp->next) { if (wp->log_fd > -1 && wp->log_fd != fpm_log_fd) { @@ -136,6 +145,11 @@ int fpm_log_write(char *log_format) /* {{{ */ } proc = *proc_p; fpm_scoreboard_proc_release(proc_p); + + if (fpm_ping_path && fpm_ping_dontlog && !strcasecmp(proc.request_uri, fpm_ping_path) + && (!strcasecmp(proc.request_method, "GET") || !strcasecmp(proc.request_method, "HEAD"))) { + return 0; + } } token = 0; diff --git a/sapi/fpm/www.conf.in b/sapi/fpm/www.conf.in index 3d5658a65d..eb589b7e4e 100644 --- a/sapi/fpm/www.conf.in +++ b/sapi/fpm/www.conf.in @@ -271,6 +271,11 @@ pm.max_spare_servers = 3 ; Default Value: pong ;ping.response = pong +; This directive may be used to apply (or prevent) the "GET /ping" to be logged. +; The directive "ping.path" have to be set before this setting to be effective. +; Default Value: yes +;ping.dontlog = yes + ; The access log file ; Default: not set ;access.log = log/$pool.access.log