Skip to content

Commit 76e407e

Browse files
authored
Merge pull request #4660 from sysown/v2.7-4658_4659
V2.7 features after crash: `--initial` and TLS reload , #4658 and #4659
2 parents d164bd1 + 774b405 commit 76e407e

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/main.cpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -1380,15 +1380,15 @@ bool ProxySQL_daemonize_phase2() {
13801380
* @note This function does not return if an error occurs; it exits the process.
13811381
*/
13821382
void call_execute_on_exit_failure() {
1383+
// Log a message indicating the attempt to call the external script
1384+
proxy_info("Trying to call external script after exit failure: %s\n", GloVars.execute_on_exit_failure ? GloVars.execute_on_exit_failure : "(null)");
1385+
13831386
// Check if the global variable execute_on_exit_failure is NULL
13841387
if (GloVars.execute_on_exit_failure == NULL) {
13851388
// Exit the function if the variable is not set
13861389
return;
13871390
}
13881391

1389-
// Log a message indicating the attempt to call the external script
1390-
proxy_error("Trying to call external script after exit failure: %s\n", GloVars.execute_on_exit_failure);
1391-
13921392
// Fork a child process
13931393
pid_t cpid;
13941394
cpid = fork();
@@ -1474,6 +1474,16 @@ bool ProxySQL_daemonize_phase3() {
14741474
proxy_info("ProxySQL SHA1 checksum: %s\n", binary_sha1);
14751475
}
14761476
call_execute_on_exit_failure();
1477+
// automatic reload of TLS certificates after a crash , see #4658
1478+
std::string msg;
1479+
ProxySQL_create_or_load_TLS(false, msg);
1480+
// Honor --initial after a crash , see #4659
1481+
if (GloVars.__cmd_proxysql_initial==true) {
1482+
std::cerr << "Renaming database file " << GloVars.admindb << endl;
1483+
char *newpath=(char *)malloc(strlen(GloVars.admindb)+8);
1484+
sprintf(newpath,"%s.bak",GloVars.admindb);
1485+
rename(GloVars.admindb,newpath); // FIXME: should we check return value, or ignore whatever it successed or not?
1486+
}
14771487
parent_close_error_log();
14781488
return false;
14791489
}

0 commit comments

Comments
 (0)