From 67dd1468cf024b9003150e98db1a630ef42a9cb5 Mon Sep 17 00:00:00 2001 From: feiniks <36756310+feiniks@users.noreply.github.com> Date: Fri, 15 Dec 2023 10:24:26 +0800 Subject: [PATCH] Add debug mode for seafdav (#641) * Add debug mode for seafdav * Use seafdav conf --------- Co-authored-by: yangheran --- controller/seafile-controller.c | 51 ++++++++++++++++++++++++--------- controller/seafile-controller.h | 1 + 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/controller/seafile-controller.c b/controller/seafile-controller.c index 8d15edf7..a81fce17 100644 --- a/controller/seafile-controller.c +++ b/controller/seafile-controller.c @@ -370,19 +370,35 @@ start_seafdav() { char port[16]; snprintf (port, sizeof(port), "%d", conf.port); - char *argv[] = { - (char *)get_python_executable(), - "-m", "wsgidav.server.server_cli", - "--server", "gunicorn", - "--root", "/", - "--log-file", seafdav_log_file, - "--pid", ctl->pidfile[PID_SEAFDAV], - "--port", port, - "--host", conf.host, - NULL - }; - - int pid = spawn_process (argv, true); + int pid; + if (conf.debug_mode) { + char *argv[] = { + (char *)get_python_executable(), + "-m", "wsgidav.server.server_cli", + "--server", "gunicorn", + "--root", "/", + "--log-file", seafdav_log_file, + "--pid", ctl->pidfile[PID_SEAFDAV], + "--port", port, + "--host", conf.host, + "-v", + NULL + }; + pid = spawn_process (argv, true); + } else { + char *argv[] = { + (char *)get_python_executable(), + "-m", "wsgidav.server.server_cli", + "--server", "gunicorn", + "--root", "/", + "--log-file", seafdav_log_file, + "--pid", ctl->pidfile[PID_SEAFDAV], + "--port", port, + "--host", conf.host, + NULL + }; + pid = spawn_process (argv, true); + } if (pid <= 0) { seaf_warning ("Failed to spawn seafdav\n"); @@ -779,6 +795,15 @@ read_seafdav_config() g_clear_error (&error); } + ctl->seafdav_config.debug_mode = g_key_file_get_boolean (key_file, "WEBDAV", "debug", &error); + if (error != NULL) { + if (error->code != G_KEY_FILE_ERROR_KEY_NOT_FOUND) { + seaf_message ("Error when reading WEBDAV.debug, use deafult value FALSE\n"); + } + ctl->seafdav_config.debug_mode = FALSE; + g_clear_error (&error); + } + if (ctl->seafdav_config.port <= 0 || ctl->seafdav_config.port > 65535) { seaf_warning("Failed to load seafdav config: invalid port %d\n", ctl->seafdav_config.port); ret = -1; diff --git a/controller/seafile-controller.h b/controller/seafile-controller.h index bf9e4c07..53f4061a 100644 --- a/controller/seafile-controller.h +++ b/controller/seafile-controller.h @@ -35,6 +35,7 @@ typedef struct SeafDavConfig { gboolean enabled; int port; char *host; + gboolean debug_mode; } SeafDavConfig;