225 Commits

Author SHA1 Message Date
Stephane Wirtel
7ed7ca998d Close all the listener sockets 2013-08-27 11:24:32 +02:00
benoitc
532d1fffaf document the use of PYTHONUNBUFFERED in config 2013-04-23 16:23:46 +02:00
benoitc
29aefcc1cf only close 0-2 fds when -R isn't specified
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.
2013-04-23 16:23:46 +02:00
benoitc
208df4ddd9 let the VM close the sockets on exit
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
2013-04-23 08:38:03 +02:00
benoitc
612f4125dd make sure we exit immediately if we fail to load the application.
While I'm here describe a more accurate error when it happens.

fix #508
2013-04-22 18:43:20 +02:00
benoitc
3ade8e8d78 make harder for workers to listen at the same time
fix #514
2013-04-22 18:10:18 +02:00
benoitc
765839b2ad we only care of it if gunicorn was started as a daemon
fix #466
2013-04-21 07:00:03 +02:00
Chris Streeter
e908ec3359 Consistently get CWD across apps and arbiter.
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.
2013-04-03 11:15:53 +02:00
Chris Streeter
5b7696f032 Fix a typo. 2013-02-19 18:28:54 -08:00
Adnane Belmadiaf
20cd49595a PEP8 fixes 2012-12-24 09:53:03 +01:00
Adnane Belmadiaf
1c9b8460b1 s/create_sockeSt/create_sockets 2012-12-22 08:58:46 +01:00
Qiangning Hong
174c34ec9c add nworkers_changed hook
This hook will be called whenever the number of workers is set.
2012-12-21 15:43:26 +01:00
benoitc
b7b51adf13 allows gunicorn to bind to multiple address
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
2012-12-14 10:18:39 +01:00
sib
771aae85e0 fixed: PWD comparison in arbiter using incorrect attribute names 2012-11-22 23:29:25 -05:00
benoitc
46e041b9f1 don't use map 2012-11-16 11:08:02 +01:00
Andrew Gorcester
f7b9a08c9c resolve py3 bytes issue for django apps 2012-10-28 06:33:07 +01:00
benoitc
8d453fb341 all tests pass under python 3 2012-10-24 22:07:35 +02:00
benoitc
53ce50bc7b obvious syntax fixes preparing python3 support 2012-10-24 12:11:15 +02:00
Xie Shi
274e43489b Workers won't be killed if timeout set to 0 2012-09-27 19:14:41 +02:00
Djoume Salvetti
97b43bd20a Create a pidfile before executing on_starting().
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.
2012-08-03 21:27:36 +02:00
benoitc
3cd1a9acd9 log it as an exception 2012-08-03 06:04:08 +02:00
benoitc
67bd75f7b3 don't try to reopen files on initial startup. fix #358 2012-06-24 17:25:43 +02:00
benoitc
a68618c824 breaking change: take the control on graceful reload back
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.
2012-06-18 11:02:30 +02:00
benoitc
cd3f9f076e logs are already reopened in self.setup 2012-06-04 11:55:29 +02:00
benoitc
188fa3e109 add the graceful timeout option. close #352
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.
2012-06-01 09:07:43 +02:00
Benoit Chesneau
1c27d369b4 display traceback when the work fails to boot (close #338) 2012-04-26 17:40:09 +02:00
benoitc
ff1dfa1780 reopen log files after initialization . close #309
make sure we reopen logfiles after initialization so we are sure we can
use it.
2012-03-24 09:46:05 +01:00
Chris Forbes
feb200d807 Fix typo in docstring for kill_workers 2012-03-20 15:53:32 +13:00
benoitc
f168a21dae fix whitespaces 2012-02-19 11:27:46 +01:00
Sergey Rublev
8bf793d2e5 Fix missed argument during refactoring 2012-02-01 11:59:53 -05:00
Evan Mezeske
d53112bbb2 iremove reap_workers from signaling . 2011-11-10 05:53:02 +01:00
Evan Mezeske
3c1f1cb126 Don't call logging functions in the signal handler.
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.
2011-10-25 21:54:26 +02:00
Randall Leeds
58c3c5680d typo 2011-10-05 14:11:55 -07:00
Randall Leeds
4b53236034 fix #245 - try to prevent leaking fds on reexec 2011-09-19 13:42:07 -07:00
benoitc
824801d017 make the Logger pluggable. Allows people to use their own logger by
giving to gunicorn an entry point or a module path.
2011-09-09 00:43:00 +02:00
Phil Schanely
d6560726c5 New on_reload server hook to customize how SIGHUPs spawn new workers. 2011-08-22 09:45:06 +02:00
Denis Bilenko
32862a694a when stopping the arbiter, close the listener asap
setting self.LISTENER to None is not enough because
self.WORKERS also have references to it
2011-08-21 22:47:35 -07:00
Randall Leeds
1ebf60fbc3 reopen logs on USR1 to master 2011-08-21 22:47:35 -07:00
benoitc
66f7271c5f Use our own logger object to log events in gunicorn. While I'm here add
the possibility to manage an access log compatible with apache combined
log format. reopening files is also handled. Also, this change fix
issues #237 and #190.

For the sake of simplicity logging file have been removed

--logfile option has become --error-logfile, by default "-"

Following options have been added:

--access-logfile, the access log file path. By default None. If set
access logs will bre written to defined output

eg:

$ gunicorn -w3 --access-logfile=- test:app
2011-08-21 19:36:52 [84572] [INFO] Starting gunicorn 0.13.0
2011-08-21 19:36:52 [84572] [INFO] Listening at: http://127.0.0.1:8000
(84572)
2011-08-21 19:36:52 [84572] [INFO] Using worker: sync
2011-08-21 19:36:52 [84573] [INFO] Booting worker with pid: 84573
2011-08-21 19:36:52 [84574] [INFO] Booting worker with pid: 84574
2011-08-21 19:36:52 [84575] [INFO] Booting worker with pid: 84575
127.0.0.1 - - [21/Aug/2011:19:37:04] "GET / HTTP/1.1" 200 14 "-"
"curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r
zlib/1.2.5"
2011-08-21 21:08:58 +02:00
Paul J. Davis
0923a52171 Fix bug in Arbiter.manage_workers.
My fix yesterday was broken when sorting workers. Thanks to
Sabin Iacob for the report.
2011-06-15 09:20:20 -04:00
Paul J. Davis
6d69509bb6 Avoid race condition in dict iteration.
Its possible that when iterating Arbiter.WORKERS in manage_workers we
get interupted to handle a SIGCHLD which will pop the child PID from
the dict which results in a "dict changed size while iterating
error. Reported on IRC. Simple fix is to just copy the dict into a
list that we iterate.
2011-06-14 16:17:47 -04:00
WoLpH
179b87639c removed python string formatting from logging to enable log message grouping 2011-05-11 23:11:36 +02:00
Michael Schurter
1a52dd2d84 Remove unneeded lambda 2011-05-11 23:11:03 +02:00
Neil Chintomby
06987d3702 add server hook "on_starting" to allow socket patching to allow gevent worker reloading. 2011-03-14 23:28:33 -04:00
benoitc
dbc61f310e fix issue #143. unnecessary list(). 2011-03-06 10:24:56 +01:00
benoitc
14313985d6 add worker info at startup. 2011-03-03 10:05:16 +01:00
benoitc
16fd5d3c20 remove some useless code. pyflakes my friend. 2010-12-22 19:52:34 +01:00
benoitc
c90ecd1eba put back murder_workers. We are not sure there isn't a border effect with
active_workers patch. So postpone it for 0.12.1 waiting more feedbacks
and tests. "<davisp> Sounds good ot me"
2010-12-22 18:34:57 +01:00
benoitc
b62055d529 fail sooner on user and group error. Fix issue #75.
Note: the process could be extended to other variable that need specific
parsing.
2010-12-12 12:38:47 +01:00
Randall Leeds
29a8254b22 don't kill old workers until new ones are active 2010-12-02 12:30:57 -05:00