diff --git a/docs/source/deploy.rst b/docs/source/deploy.rst index 152f1309..adfa7073 100644 --- a/docs/source/deploy.rst +++ b/docs/source/deploy.rst @@ -262,7 +262,7 @@ systemd: WorkingDirectory=/home/urban/gunicorn/bin ExecStart=/home/someuser/gunicorn/bin/gunicorn -p /home/urban/gunicorn/gunicorn.pid- test:app ExecReload=/bin/kill -s HUP $MAINPID - ExecStop=/bin/kill -s QUIT $MAINPID + ExecStop=/bin/kill -s TERM $MAINPID PrivateTmp=true **gunicorn.socket**:: diff --git a/docs/source/settings.rst b/docs/source/settings.rst index 58e179fb..9eee8b2e 100644 --- a/docs/source/settings.rst +++ b/docs/source/settings.rst @@ -727,7 +727,7 @@ worker_int def worker_int(worker): pass -Called just after a worker exited on SIGINT or SIGTERM. +Called just after a worker exited on SIGINT or SIGQUIT. The callable needs to accept one instance variable for the initialized Worker. diff --git a/docs/source/signals.rst b/docs/source/signals.rst index c37a34f3..c041a364 100644 --- a/docs/source/signals.rst +++ b/docs/source/signals.rst @@ -22,7 +22,7 @@ Master process - **TTIN**: Increment the number of processes by one - **TTOU**: Decrement the nunber of processes by one - **USR1**: Reopen the log files -- **USR2**: Upgrade the Gunicorn on the fly. A separate **QUIT** signal should +- **USR2**: Upgrade the Gunicorn on the fly. A separate **TERM** signal should be used to kill the old process. This signal can also be used to use the new versions of pre-loaded applications. - **WINCH**: Gracefully shutdown the worker processes when gunicorn is @@ -91,7 +91,7 @@ incoming requests together. To phase the old instance out, you have to send **WINCH** signal to the old master process, and its worker processes will start to gracefully shut down. -t this point you can still revert to the old server because it hasn't closed its listen sockets yet, by following these steps: +At this point you can still revert to the old server because it hasn't closed its listen sockets yet, by following these steps: - Send HUP signal to the old master process - it will start the worker processes without reloading a configuration file - Send TERM signal to the new master process to gracefully shut down its worker processes diff --git a/examples/example_config.py b/examples/example_config.py index c939b851..7341447b 100644 --- a/examples/example_config.py +++ b/examples/example_config.py @@ -202,7 +202,7 @@ def when_ready(server): server.log.info("Server is ready. Spwawning workers") def worker_int(worker): - worker.log.info("worker received INT or TERM signal") + worker.log.info("worker received INT or QUIT signal") ## get traceback info import threading, sys, traceback diff --git a/examples/when_ready.conf.py b/examples/when_ready.conf.py index 61a04df3..578caacb 100644 --- a/examples/when_ready.conf.py +++ b/examples/when_ready.conf.py @@ -29,7 +29,7 @@ class MemoryWatch(threading.Thread): if self.memory_usage(pid) > self.max_mem: self.server.log.info("Pid %s killed (memory usage > %s)", pid, self.max_mem) - self.server.kill_worker(pid, signal.SIGQUIT) + self.server.kill_worker(pid, signal.SIGTERM) time.sleep(self.timeout) diff --git a/gunicorn/arbiter.py b/gunicorn/arbiter.py index a05750ea..4489b7df 100644 --- a/gunicorn/arbiter.py +++ b/gunicorn/arbiter.py @@ -229,7 +229,7 @@ class Arbiter(object): raise StopIteration def handle_quit(self): - "SIGTERM handling" + "SIGQUIT handling" self.stop(False) raise StopIteration @@ -273,7 +273,7 @@ class Arbiter(object): if self.cfg.daemon: self.log.info("graceful stop of workers") self.num_workers = 0 - self.kill_workers(signal.SIGQUIT) + self.kill_workers(signal.SIGTERM) else: self.log.debug("SIGWINCH ignored. Not daemonized") @@ -480,7 +480,7 @@ class Arbiter(object): workers = sorted(workers, key=lambda w: w[1].age) while len(workers) > self.num_workers: (pid, _) = workers.pop(0) - self.kill_worker(pid, signal.SIGQUIT) + self.kill_worker(pid, signal.SIGTERM) def spawn_worker(self): self.worker_age += 1 diff --git a/gunicorn/config.py b/gunicorn/config.py index 5a165724..d940fa19 100644 --- a/gunicorn/config.py +++ b/gunicorn/config.py @@ -1369,7 +1369,7 @@ class WorkerInt(Setting): default = staticmethod(worker_int) desc = """\ - Called just after a worker exited on SIGINT or SIGTERM. + Called just after a worker exited on SIGINT or SIGQUIT. The callable needs to accept one instance variable for the initialized Worker. diff --git a/gunicorn/workers/base.py b/gunicorn/workers/base.py index 99c68c8f..b0bc50ab 100644 --- a/gunicorn/workers/base.py +++ b/gunicorn/workers/base.py @@ -83,7 +83,7 @@ class Worker(object): if self.cfg.reload: def changed(fname): self.log.info("Worker reloading: %s modified", fname) - os.kill(self.pid, signal.SIGTERM) + os.kill(self.pid, signal.SIGQUIT) raise SystemExit() Reloader(callback=changed).start() @@ -130,10 +130,10 @@ class Worker(object): signal.signal(signal.SIGUSR1, self.handle_usr1) signal.signal(signal.SIGABRT, self.handle_abort) - # Don't let SIGQUIT and SIGUSR1 disturb active requests + # Don't let SIGTERM and SIGUSR1 disturb active requests # by interrupting system calls if hasattr(signal, 'siginterrupt'): # python >= 2.6 - signal.siginterrupt(signal.SIGQUIT, False) + signal.siginterrupt(signal.SIGTERM, False) signal.siginterrupt(signal.SIGUSR1, False) def handle_usr1(self, sig, frame): @@ -141,11 +141,11 @@ class Worker(object): def handle_exit(self, sig, frame): self.alive = False - # worker_int callback - self.cfg.worker_int(self) def handle_quit(self, sig, frame): self.alive = False + # worker_int callback + self.cfg.worker_int(self) sys.exit(0) def handle_abort(self, sig, frame):