Move setting of env vars from Arbiter.start to Arbiter.setup so that they are available during application start up when 'preload_app' is used.
Closes#735
Commit 81241907ffcf94517ffa14b8427205906b61b540 changed the signal
handling by switching the roles of `TERM` and `QUIT` for the arbiter
so that `TERM` is graceful and `QUIT` is not.
At the time, workers performed graceful shutdown on `QUIT` and quick
shutdown on `TERM` and `INT`. This behavior was also changed so that
`QUIT` (and `INT`) cause a quick shutdown and `TERM` is graceful.
However, the documentation incorrectly reversed the roles of the worker
signals and the arbiter was not updated to use the correct signals.
This commit fixes the documentation and the arbiter signals.
I can't imagine this wasn't what was intended here. Might be a merge
artifact but I can't trace it.
Thanks to Antti Kaihola (@akaihola) for spotting this.
Close#733
This commit tries to minimize the chance of sending a kill signal
to a process that is not a gunicorn worker by reaping children
as soon as the SIGCHLD is received.
Close#371
"Limits the number of worker processes to 1" hasn't been true since
06a4dc6 (fix one error in gunicorn_paster, global conf was ignored,
2010-06-22), although it was true when the line was added in 3c7d532
(Large refactor of the documentation and website, 2010-05-22).
"changes some error handling that's sent to clients" hasn't been true
since feb86d3 (don't display the traceback in the HTTP response,
2013-09-27).
The only remaining actions that --debug had were disabling --preload
and hiding debug-level config logging. The former seems useless (just
disable --preload directly) and the latter at doesn't seem useful
enough for a new setting (just turn down --log-level). With this
commit, --preload always works and you always get debug-level config
logging.
I left a stub Debug entry in gunicorn.config, which we can leave in
place while folks convert any gunicorn scripts and configurations to
drop --debug. When the time comes, we can just remove that entry. I
also the boolean-config tests to use --preload, since that will still
be around after we remove the dummy Debug entry.
Fixes#700.
`cfg.worker_class` is a property, which calls the classmethod `setup` of
the worker class when accessed. Gevent worker relies on this mechanism
to call `gevent.monkey.patch_all()`.
However, `num_workers` is a hooked property, when it is set, gunicorn
will call hook defined by user. If the hooked code relies on
gevent's monkey patch, it will fail because the monkey patch has not
been applied yet.
This commit makes sure that `worker_class` property getter invokes
before `num_workers` setter to resolve this problem.
SIGWINCH could happen often in the console when the terminal is resized.
Since the error is harmless just display it when the logging level is
debug.
fix#449
This command line argunment allows someone to pass an environement variable to
gunicorn:
$ gunicorn --env FOO=1 test:app
With the command line above the application will be able to use the FOO
environment vatriable.
Following some discussion on IRC with @GrahamDumpleton this patch only
close stdios if -R isn't specified. It also let others fds open and
don't try to close them.
This should fix logging around and behave like other daemons. It should
also close#309.
Closing sockets when stopping the arbiter was also closing unix sockets
if any because they aren't attached to a specific process. So remove it
and let the vm close them if needed. This change fix the reload of the
binary.
fix#476
The Arbiter is smart about getting the CWD; first it checks the CWD
environment (which doesn't resolve symlinks), then it falls back to the
python os.getcwd() (which does resolve symlinks). However, the Arbiter
is the only place that does this, which will then do the right thing
when we reexec. However, when reloading the Arbiter, it won't pick up
changes if the symlink has changed.
By changing the *app.py entry points to also use the same method for
determining the CWD, we'll insert a symlink path into the first location
in sys.path. Then our reloaded app will correctly pull in any new
changes.
Allows gunicorn to listen on different interface. It can be either ipv6,
unix or ipv4 sockets.
Ex:
gunicorn -w3 -b 127.0.0.1:8001 -b 127.0.0.1:8000 -b [::1]:8000 test:app
fix#444
This will let a standard init script (or any script that look for a
pidfile) know that gunicorn is already running and won't attempt to run
it twice.
This would also enable the script to stop gunicorn even in it's startup
phase.
We really shouldn't allow the people to override the way we spawn the
new workers on reload. Graceful is about launching new worker and kill
olders after the graceful time.
This change add gtraceful timeout option. This timeout is different than
the worker timeout and can be extended to handled a longer delay before
closing a running connection.
Patch based on the one given by @sirkonst with some edit + support of
the eventlet worker.
The standard logger uses locking functions which are NOT guaranteed to
be re-entrant [1], so this could (potentially) result in deadlock or a
crash.
[1] http://docs.python.org/library/logging.html Section 15.7.8.