daemons throttling subsystem

This commit is contained in:
roberto@djangocloud
2011-10-18 18:53:22 +10:00
parent 03266203fd
commit 0065152bb1
+10
View File
@@ -2240,6 +2240,11 @@ void spawn_daemon(struct uwsgi_daemon *ud) {
char *a;
int cnt = 1;
int devnull = -1;
int throttle = 0;
if (uwsgi.current_time - ud->last_spawn <= 3) {
throttle = ud->respawns - (uwsgi.current_time-ud->last_spawn);
}
pid_t pid = uwsgi_fork("uWSGI external daemon");
if (pid < 0) {
@@ -2304,6 +2309,11 @@ void spawn_daemon(struct uwsgi_daemon *ud) {
argv[cnt] = NULL;
if (throttle) {
uwsgi_log_verbose("throttling %s for %d seconds\n", argv[0], throttle);
sleep(throttle);
}
uwsgi_log_verbose("running %s\n", argv[0]);
if (execvp(argv[0], argv)) {
uwsgi_error("execvp()");