Add ability to recover somewhat from a dead master node

ulab-next
Timothy Pearson 13 years ago committed by Timothy Pearson
parent 7b7a6adb71
commit cf13a16ce2

@ -103,6 +103,35 @@ char raptor_sm_deallocate_session(char* username) {
return 1;
}
pid_t serverpid = raptor_sm_get_pid_for_username(username);
if (serverpid >= 0) {
// Verify existence of PID on remote server
dprint("Verifying process %d on %s...\n\r", serverpid, row[1]);
char* ip = raptor_sm_get_ip_for_hostname(row[1], 0);
char* command_string;
asprintf(&command_string, "ssh root@%s \'ps -p %d | grep %d\'", ip, serverpid, serverpid);
FILE *fp;
char output[1024];
// Open the command for reading
fp = popen(command_string, "r");
if (fp == NULL) {
mysql_close(conn);
return -1;
}
// Read the output a line at a time
fgets(output, sizeof(output)-1, fp);
// Close output
pclose(fp);
free(command_string);
free(ip);
dprint("...result was %s\n\r", output);
if (strcmp(output, "") != 0) {
mysql_free_result(res);
mysql_close(conn);
return 0;
}
}
// Remove the user from the system
char* safe_username = get_mysql_escaped_string(conn, username);
asprintf(&query, "DELETE FROM sessions WHERE username='%s'", safe_username);

Loading…
Cancel
Save