Skip to content

Commit

Permalink
Add debug mode for seafdav
Browse files Browse the repository at this point in the history
  • Loading branch information
yangheran committed Dec 14, 2023
1 parent ce8a8db commit 7d3000a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 11 deletions.
47 changes: 36 additions & 11 deletions controller/seafile-controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,17 +370,33 @@ 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
};
char *argv[];
if (ctr->seafdav_conf->debug_mode) {
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
};
} else {
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);

Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions controller/seafile-controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ typedef struct SeafDavConfig {
gboolean enabled;
int port;
char *host;
gboolean debug_mode;

} SeafDavConfig;

Expand Down

0 comments on commit 7d3000a

Please sign in to comment.