Skip to content

Commit

Permalink
add SIGUSR1 handler to trigger PROXYSQL FLUSH LOGS
Browse files Browse the repository at this point in the history
  • Loading branch information
mirostauder committed Apr 9, 2024
1 parent 6d9252a commit 3e3b6ec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/ProxySQL_Admin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1837,7 +1837,9 @@ bool admin_handler_command_proxysql(char *query_no_space, unsigned int query_no_
}
free(ssl_keylog_file);
}
SPA->send_MySQL_OK(&sess->client_myds->myprot, NULL);
if (sess != NULL) {
SPA->send_MySQL_OK(&sess->client_myds->myprot, NULL);
}
return false;
}

Expand Down
11 changes: 11 additions & 0 deletions lib/ProxySQL_GloVars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@
#include "MySQL_LDAP_Authentication.hpp"

extern MySQL_LDAP_Authentication* GloMyLdapAuth;
extern bool admin_handler_command_proxysql(char* query_no_space, unsigned int query_no_spcae_lenght, MySQL_Session *sess, ProxySQL_Admin *pa);
extern ProxySQL_Admin *GloAdmin;

static void log_handler(int sig) {
proxy_warning("Received SIGUSR1 signal: PROXYSQL FLUSH LOGS; in progress...\n");
/*
Support system logging facilities sending SIGUSR1 to do log rotation
*/
admin_handler_command_proxysql("PROXYSQL FLUSH LOGS", 19, NULL, GloAdmin);
}

static void term_handler(int sig) {
proxy_warning("Received TERM signal: shutdown in progress...\n");
Expand Down Expand Up @@ -299,6 +309,7 @@ ProxySQL_GlobalVariables::ProxySQL_GlobalVariables() :
};

void ProxySQL_GlobalVariables::install_signal_handler() {
signal(SIGUSR1, log_handler);
signal(SIGTERM, term_handler);
signal(SIGSEGV, crash_handler);
signal(SIGABRT, crash_handler);
Expand Down

0 comments on commit 3e3b6ec

Please sign in to comment.