mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-06-16 02:15:48 +00:00
spooler-signal-as-task
This commit is contained in:
+5
-4
@@ -467,8 +467,7 @@ cycle:
|
||||
return received_signal;
|
||||
}
|
||||
|
||||
void uwsgi_receive_signal(struct wsgi_request *wsgi_req, int fd, char *name, int id) {
|
||||
|
||||
pid_t uwsgi_receive_signal(struct wsgi_request *wsgi_req, int fd, char *name, int id) {
|
||||
uint8_t uwsgi_signal;
|
||||
|
||||
ssize_t ret = read(fd, &uwsgi_signal, 1);
|
||||
@@ -487,13 +486,15 @@ void uwsgi_receive_signal(struct wsgi_request *wsgi_req, int fd, char *name, int
|
||||
if (uwsgi_signal_handler(wsgi_req, uwsgi_signal)) {
|
||||
uwsgi_log_verbose("error managing signal %d on %s %d\n", uwsgi_signal, name, id);
|
||||
}
|
||||
return getpid();
|
||||
}
|
||||
|
||||
return;
|
||||
return -1;
|
||||
|
||||
destroy:
|
||||
// better to kill the whole worker...
|
||||
uwsgi_log_verbose("uWSGI %s %d screams: UAAAAAAH my master disconnected: I will kill myself!!!\n", name, id);
|
||||
end_me(0);
|
||||
|
||||
// never here
|
||||
return -1;
|
||||
}
|
||||
|
||||
+10
-1
@@ -423,6 +423,8 @@ void spooler(struct uwsgi_spooler *uspool) {
|
||||
|
||||
int spooler_event_queue = event_queue_init();
|
||||
int interesting_fd = -1;
|
||||
// determining which spooler process is working on signal events
|
||||
pid_t working_spooler_pid = -1;
|
||||
|
||||
if (uwsgi.master_process) {
|
||||
event_queue_add_fd_read(spooler_event_queue, uwsgi.shared->spooler_signal_pipe[1]);
|
||||
@@ -465,7 +467,14 @@ void spooler(struct uwsgi_spooler *uspool) {
|
||||
if (event_queue_wait(spooler_event_queue, timeout, &interesting_fd) > 0) {
|
||||
if (uwsgi.master_process) {
|
||||
if (interesting_fd == uwsgi.shared->spooler_signal_pipe[1]) {
|
||||
uwsgi_receive_signal(NULL, interesting_fd, "spooler", (int) getpid());
|
||||
working_spooler_pid = uwsgi_receive_signal(NULL, interesting_fd, "spooler", (int) getpid());
|
||||
if (uwsgi.spooler_signal_as_task && working_spooler_pid == uwsgi.mypid) {
|
||||
uspool->tasks++;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,6 +326,7 @@ static struct uwsgi_option uwsgi_base_options[] = {
|
||||
{"spooler-processes", required_argument, 0, "set the number of processes for spoolers", uwsgi_opt_set_int, &uwsgi.spooler_numproc, UWSGI_OPT_IMMEDIATE},
|
||||
{"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},
|
||||
{"spooler-signal-as-task", no_argument, 0, "treat signal events as tasks in spooler, combine used with spooler-max-tasks", uwsgi_opt_true, &uwsgi.spooler_signal_as_task, 0},
|
||||
{"spooler-harakiri", required_argument, 0, "set harakiri timeout for spooler tasks", uwsgi_opt_set_int, &uwsgi.harakiri_options.spoolers, 0},
|
||||
{"spooler-frequency", required_argument, 0, "set spooler frequency", uwsgi_opt_set_int, &uwsgi.spooler_frequency, 0},
|
||||
{"spooler-freq", required_argument, 0, "set spooler frequency", uwsgi_opt_set_int, &uwsgi.spooler_frequency, 0},
|
||||
|
||||
@@ -2374,6 +2374,7 @@ struct uwsgi_server {
|
||||
int spooler_ordered;
|
||||
int spooler_quiet;
|
||||
int spooler_frequency;
|
||||
int spooler_signal_as_task;
|
||||
|
||||
int snmp;
|
||||
char *snmp_addr;
|
||||
@@ -4000,7 +4001,7 @@ int uwsgi_is_file2(char *, struct stat *);
|
||||
int uwsgi_is_dir(char *);
|
||||
int uwsgi_is_link(char *);
|
||||
|
||||
void uwsgi_receive_signal(struct wsgi_request *, int, char *, int);
|
||||
pid_t uwsgi_receive_signal(struct wsgi_request *, int, char *, int);
|
||||
void uwsgi_exec_atexit(void);
|
||||
|
||||
struct uwsgi_stats {
|
||||
|
||||
Reference in New Issue
Block a user