Skip to content

Commit

Permalink
Merge pull request #4660 from sysown/v2.7-4658_4659
Browse files Browse the repository at this point in the history
V2.7 features after crash: `--initial` and TLS reload , #4658 and #4659
  • Loading branch information
renecannao authored Sep 20, 2024
2 parents d164bd1 + 774b405 commit 76e407e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1380,15 +1380,15 @@ bool ProxySQL_daemonize_phase2() {
* @note This function does not return if an error occurs; it exits the process.
*/
void call_execute_on_exit_failure() {
// Log a message indicating the attempt to call the external script
proxy_info("Trying to call external script after exit failure: %s\n", GloVars.execute_on_exit_failure ? GloVars.execute_on_exit_failure : "(null)");

// Check if the global variable execute_on_exit_failure is NULL
if (GloVars.execute_on_exit_failure == NULL) {
// Exit the function if the variable is not set
return;
}

// Log a message indicating the attempt to call the external script
proxy_error("Trying to call external script after exit failure: %s\n", GloVars.execute_on_exit_failure);

// Fork a child process
pid_t cpid;
cpid = fork();
Expand Down Expand Up @@ -1474,6 +1474,16 @@ bool ProxySQL_daemonize_phase3() {
proxy_info("ProxySQL SHA1 checksum: %s\n", binary_sha1);
}
call_execute_on_exit_failure();
// automatic reload of TLS certificates after a crash , see #4658
std::string msg;
ProxySQL_create_or_load_TLS(false, msg);
// Honor --initial after a crash , see #4659
if (GloVars.__cmd_proxysql_initial==true) {
std::cerr << "Renaming database file " << GloVars.admindb << endl;
char *newpath=(char *)malloc(strlen(GloVars.admindb)+8);
sprintf(newpath,"%s.bak",GloVars.admindb);
rename(GloVars.admindb,newpath); // FIXME: should we check return value, or ignore whatever it successed or not?
}
parent_close_error_log();
return false;
}
Expand Down

0 comments on commit 76e407e

Please sign in to comment.