Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added --spooler-max-tasks

  • Loading branch information...
commit 8ba032adb248e80835e444c3b585ec517a072f58 1 parent 1a61dfd
roberto@precise64 authored
Showing with 14 additions and 0 deletions.
  1. +11 −0 spooler.c
  2. +1 −0  uwsgi.c
  3. +2 −0  uwsgi.h
View
11 spooler.c
@@ -310,6 +310,9 @@ void spooler(struct uwsgi_spooler *uspool) {
event_queue_add_fd_read(spooler_event_queue, uwsgi.shared->spooler_signal_pipe[1]);
}
+ // reset the tasks counter
+ uspool->tasks = 0;
+
for (;;) {
@@ -361,6 +364,12 @@ void spooler(struct uwsgi_spooler *uspool) {
}
wakeup = tmp_wakeup;
+ // need to recycle ?
+ if (uwsgi.spooler_max_tasks > 0 && uspool->tasks >= (uint64_t)uwsgi.spooler_max_tasks) {
+ uwsgi_log("[spooler %s pid: %d] maximum number of tasks reached (%d) recycling ...\n", uspool->dir, (int) uwsgi.mypid, uwsgi.spooler_max_tasks);
+ end_me(0);
+ }
+
}
}
@@ -532,6 +541,8 @@ void spooler_manage_task(struct uwsgi_spooler *uspool, char *dir, char *task) {
}
if (ret == 0) continue;
callable_found = 1;
+ // increase task counter
+ uspool->tasks++;
if (ret == -2) {
if (!uwsgi.spooler_quiet)
uwsgi_log("[spooler %s pid: %d] done with task %s after %d seconds\n", uspool->dir, (int) uwsgi.mypid, task, time(NULL)-now);
View
1  uwsgi.c
@@ -170,6 +170,7 @@ static struct uwsgi_option uwsgi_base_options[] = {
{"spooler-chdir", required_argument, 0, "chdir() to specified directory before each spooler task", uwsgi_opt_set_str, &uwsgi.spooler_chdir,0},
{"spooler-processes", required_argument, 0, "set the number of processes for spoolers", uwsgi_opt_set_int, &uwsgi.spooler_numproc, 0},
{"spooler-quiet", no_argument, 0, "do not be verbose with spooler tasks", uwsgi_opt_true, &uwsgi.spooler_quiet, 0},
+ {"spooler-max-tasks", required_argument, 0, "set the maximum number of tasks to run before recycling a spooler", uwsgi_opt_set_int, &uwsgi.spooler_max_tasks, 0},
#endif
{"mule", optional_argument, 0, "add a mule", uwsgi_opt_add_mule, NULL, UWSGI_OPT_MASTER},
{"mules", required_argument, 0, "add the specified number of mules", uwsgi_opt_add_mules, NULL, UWSGI_OPT_MASTER},
View
2  uwsgi.h
@@ -720,6 +720,7 @@ struct uwsgi_spooler {
char dir[PATH_MAX];
pid_t pid;
uint64_t respawned;
+ uint64_t tasks;
struct uwsgi_lock_item *lock;
time_t harakiri;
@@ -1340,6 +1341,7 @@ struct uwsgi_server {
int spooler_numproc;
struct uwsgi_spooler *i_am_a_spooler;
char *spooler_chdir;
+ int spooler_max_tasks;
int spooler_ordered;
int spooler_quiet;
#endif
Please sign in to comment.
Something went wrong with that request. Please try again.