mirror of
https://github.com/haiwen/seafile-server.git
synced 2025-08-01 15:19:14 +00:00
Support seafevents.
This commit is contained in:
parent
106ee11eea
commit
39ffb0a162
@ -348,6 +348,42 @@ setup_env ()
|
||||
setup_python_path();
|
||||
}
|
||||
|
||||
static int
|
||||
start_seafevents() {
|
||||
if (!ctl->has_seafevents)
|
||||
return 0;
|
||||
|
||||
static char *seafevents_config_file = NULL;
|
||||
static char *seafevents_log_file = NULL;
|
||||
|
||||
if (seafevents_config_file == NULL)
|
||||
seafevents_config_file = g_build_filename (topdir,
|
||||
"conf/seafevents.conf",
|
||||
NULL);
|
||||
if (seafevents_log_file == NULL)
|
||||
seafevents_log_file = g_build_filename (ctl->logdir,
|
||||
"seafevents.log",
|
||||
NULL);
|
||||
|
||||
char *argv[] = {
|
||||
(char *)get_python_executable(),
|
||||
"-m", "seafevents.main",
|
||||
"--config-file", seafevents_config_file,
|
||||
"--logfile", seafevents_log_file,
|
||||
"-P", ctl->pidfile[PID_SEAFEVENTS],
|
||||
NULL
|
||||
};
|
||||
|
||||
int pid = spawn_process (argv);
|
||||
|
||||
if (pid <= 0) {
|
||||
seaf_warning ("Failed to spawn seafevents.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
start_seafdav() {
|
||||
static char *seafdav_log_file = NULL;
|
||||
@ -446,6 +482,11 @@ check_process (void *data)
|
||||
}
|
||||
}
|
||||
|
||||
if (ctl->has_seafevents && need_restart(PID_SEAFEVENTS)) {
|
||||
seaf_message ("seafevents need restart...\n");
|
||||
start_seafevents ();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -541,6 +582,11 @@ on_ccnet_connected ()
|
||||
if (start_seaf_server () < 0)
|
||||
controller_exit(1);
|
||||
|
||||
if (ctl->has_seafevents && need_restart(PID_SEAFEVENTS)) {
|
||||
if (start_seafevents() < 0)
|
||||
controller_exit(1);
|
||||
}
|
||||
|
||||
if (ctl->seafdav_config.enabled) {
|
||||
if (need_restart(PID_SEAFDAV)) {
|
||||
if (start_seafdav() < 0)
|
||||
@ -592,6 +638,8 @@ stop_ccnet_server ()
|
||||
kill_by_force(PID_CCNET);
|
||||
kill_by_force(PID_SERVER);
|
||||
kill_by_force(PID_SEAFDAV);
|
||||
if (ctl->has_seafevents)
|
||||
kill_by_force(PID_SEAFEVENTS);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -608,6 +656,7 @@ init_pidfile_path (SeafileController *ctl)
|
||||
ctl->pidfile[PID_CCNET] = g_build_filename (pid_dir, "ccnet.pid", NULL);
|
||||
ctl->pidfile[PID_SERVER] = g_build_filename (pid_dir, "seaf-server.pid", NULL);
|
||||
ctl->pidfile[PID_SEAFDAV] = g_build_filename (pid_dir, "seafdav.pid", NULL);
|
||||
ctl->pidfile[PID_SEAFEVENTS] = g_build_filename (pid_dir, "seafevents.pid", NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -661,6 +710,18 @@ seaf_controller_init (SeafileController *ctl,
|
||||
return -1;
|
||||
}
|
||||
|
||||
char *seafevents_config_file = g_build_filename (topdir,
|
||||
"conf/seafevents.conf",
|
||||
NULL);
|
||||
|
||||
if (!g_file_test (seafevents_config_file, G_FILE_TEST_EXISTS)) {
|
||||
seaf_message ("No seafevents.\n");
|
||||
ctl->has_seafevents = FALSE;
|
||||
} else {
|
||||
ctl->has_seafevents = TRUE;
|
||||
}
|
||||
g_free (seafevents_config_file);
|
||||
|
||||
init_pidfile_path (ctl);
|
||||
setup_env ();
|
||||
|
||||
|
@ -26,6 +26,7 @@ enum {
|
||||
PID_CCNET = 0,
|
||||
PID_SERVER,
|
||||
PID_SEAFDAV,
|
||||
PID_SEAFEVENTS,
|
||||
N_PID
|
||||
};
|
||||
|
||||
@ -56,5 +57,7 @@ struct _SeafileController {
|
||||
char *pidfile[N_PID];
|
||||
|
||||
SeafDavConfig seafdav_config;
|
||||
|
||||
gboolean has_seafevents;
|
||||
};
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user