mirror of
https://github.com/haiwen/seafile-server.git
synced 2025-09-13 13:51:53 +00:00
Merge pull request #139 from haiwen/controller_restart_ccnet
Restart ccnet if seaf-server is down.
This commit is contained in:
@@ -140,6 +140,21 @@ try_kill_process(int which)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
kill_by_force (int which)
|
||||||
|
{
|
||||||
|
if (which < 0 || which >= N_PID)
|
||||||
|
return;
|
||||||
|
|
||||||
|
char *pidfile = ctl->pidfile[which];
|
||||||
|
int pid = read_pid_from_pidfile(pidfile);
|
||||||
|
if (pid > 0) {
|
||||||
|
// if SIGKILL send success, then remove related pid file
|
||||||
|
if (kill ((pid_t)pid, SIGKILL) == 0) {
|
||||||
|
g_unlink (pidfile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Utility functions End
|
// Utility functions End
|
||||||
@@ -404,6 +419,7 @@ need_restart (int which)
|
|||||||
if (g_file_test (buf, G_FILE_TEST_IS_DIR)) {
|
if (g_file_test (buf, G_FILE_TEST_IS_DIR)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else {
|
} else {
|
||||||
|
seaf_warning ("path /proc/%d doesn't exist, restart progress [%d]\n", pid, which);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -414,7 +430,7 @@ check_process (void *data)
|
|||||||
{
|
{
|
||||||
if (need_restart(PID_SERVER)) {
|
if (need_restart(PID_SERVER)) {
|
||||||
seaf_message ("seaf-server need restart...\n");
|
seaf_message ("seaf-server need restart...\n");
|
||||||
start_seaf_server ();
|
kill_by_force (PID_CCNET);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctl->seafdav_config.enabled) {
|
if (ctl->seafdav_config.enabled) {
|
||||||
@@ -567,9 +583,9 @@ stop_ccnet_server ()
|
|||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
ccnet_client_send_cmd (ctl->sync_client, "shutdown", &error);
|
ccnet_client_send_cmd (ctl->sync_client, "shutdown", &error);
|
||||||
|
|
||||||
try_kill_process(PID_CCNET);
|
kill_by_force(PID_CCNET);
|
||||||
try_kill_process(PID_SERVER);
|
kill_by_force(PID_SERVER);
|
||||||
try_kill_process(PID_SEAFDAV);
|
kill_by_force(PID_SEAFDAV);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user