Skip to content

FPM Feature "ping.dontlog" : See Issue #8174 #8184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sapi/fpm/fpm/fpm_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,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) },
Expand Down Expand Up @@ -618,6 +619,7 @@ static void *fpm_worker_pool_config_alloc(void) /* {{{ */
wp->config->process_dumpable = 0;
wp->config->clear_env = 1;
wp->config->decorate_workers_output = 1;
wp->config->ping_dontlog = 1; /* don't log /ping entries */

if (!fpm_worker_all_pools) {
fpm_worker_all_pools = wp;
Expand Down Expand Up @@ -1733,6 +1735,7 @@ static void fpm_conf_dump(void) /* {{{ */
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));
Expand Down
1 change: 1 addition & 0 deletions sapi/fpm/fpm/fpm_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,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;
Expand Down
14 changes: 14 additions & 0 deletions sapi/fpm/fpm/fpm_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) /* {{{ */
{
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -138,6 +147,11 @@ int fpm_log_write(char *log_format) /* {{{ */
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;

memset(buffer, '\0', sizeof(buffer));
Expand Down
1 change: 1 addition & 0 deletions sapi/fpm/tests/bug68421-ipv6-access-log.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ listen = {{ADDR:IPv6:ANY}}
access.log = {{FILE:LOG:ACC}}
ping.path = /ping
ping.response = pong
ping.dontlog = no
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
Expand Down
5 changes: 5 additions & 0 deletions sapi/fpm/www.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,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
Expand Down