diff --git a/spooler.c b/spooler.c index d74364c9..0e419c8e 100644 --- a/spooler.c +++ b/spooler.c @@ -403,6 +403,12 @@ void spooler_manage_task(char *dir, char *task) { close(spool_fd); + if (uwsgi.spooler_chdir) { + if (chdir(uwsgi.spooler_chdir)) { + uwsgi_error("chdir()"); + } + } + int callable_found = 0; for(i=0;i<0xff;i++) { if (uwsgi.p[i]->spooler) { diff --git a/uwsgi.c b/uwsgi.c index 42fb934a..d114c24c 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -117,6 +117,7 @@ static struct option long_base_options[] = { #ifdef UWSGI_SPOOLER {"spooler", required_argument, 0, 'Q'}, {"spooler-ordered", no_argument, &uwsgi.spooler_ordered, 1}, + {"spooler-chdir", required_argument, 0, LONG_ARGS_SPOOLER_CHDIR}, #endif {"mule", optional_argument, 0, LONG_ARGS_MULE}, {"disable-logging", no_argument, 0, 'L'}, @@ -3516,6 +3517,9 @@ static int manage_base_opt(int i, char *optarg) { case LONG_ARGS_SPOOLER_HARAKIRI: uwsgi.shared->options[UWSGI_OPTION_SPOOLER_HARAKIRI] = atoi(optarg); return 1; + case LONG_ARGS_SPOOLER_CHDIR: + uwsgi.spooler_chdir = optarg; + return 1; case LONG_ARGS_MULE_HARAKIRI: uwsgi.shared->options[UWSGI_OPTION_MULE_HARAKIRI] = atoi(optarg); return 1; diff --git a/uwsgi.h b/uwsgi.h index 0958d90a..9ee7b53d 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -526,6 +526,7 @@ struct uwsgi_opt { #define LONG_ARGS_SPOOLER_HARAKIRI 17148 #define LONG_ARGS_MULE_HARAKIRI 17149 #define LONG_ARGS_EMPEROR_STATS 17150 +#define LONG_ARGS_SPOOLER_CHDIR 17151 #define UWSGI_OK 0 @@ -1208,6 +1209,7 @@ struct uwsgi_server { #ifdef UWSGI_SPOOLER char *spool_dir; + char *spooler_chdir; int spooler_ordered; uint64_t spooler_respawned; #endif