189 Commits

Author SHA1 Message Date
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
benoitc
ac1688fe9b fix temporary file leaking . 2010-11-20 16:51:52 +01:00
Paul J. Davis
e591059358 Set the number of workers to zero on WINCH.
We need to update the number of workers so they aren't restarted
the next time the arbiter wakes up and runs manage_workers. Also
fixed a typo for the log statement.

Thanks to Randall Leeds for the report and patch.
2010-11-15 21:37:15 -05:00
benoitc
cae9b0bece fix gunicorn paster. Now we have real HUP with paster. Also use paster
logging everywhere.
2010-10-22 06:59:46 +02:00
Paul J. Davis
3cc0e5df8a Add SERVER_SOFTWARE to the os.environ
Requested to allow a WSGI app to detect if its running in production
or development modes.
2010-09-06 15:23:30 -07:00
benoitc
7715199b48 it's better to test when you use the right code to do it. We had a
blocking operation django example (we read a file already on the fs and
recreate another which blocked async schedulers).

While I'm here ease the code of eventlet worker. Just use the convenient
eventlet.serve function which already manage what we do and revert sopme
useless changes in body and header parsing.
2010-09-02 14:55:56 +02:00
George Kollias
5a4e16cf5b * Added 'worker_exit' server hook
Fixes #81.
2010-08-16 10:50:25 -04:00
Paul J. Davis
63b53c9f51 Exit with a non-zero status if workers don't boot.
Raising a HaltServer exception in the arbiter will now exit with the
provided reason and status code.
2010-08-05 23:28:25 -04:00
Randall Leeds
17decda1e3 catch SystemExit exception and exit quietly
raised by:
1) workers started during reload (main loop) that are killed later
2) the arbiter process during Ctl-C or other halt signals
2010-08-06 01:02:20 +08:00
benoitc
8903d0d53a fix from tilgovi. thanks 2010-08-05 15:42:07 +02:00
jbergstroem
eca6fad4ce Output config if debug loglevel is set 2010-07-23 20:47:56 -04:00
jbergstroem
e99a384a22 Initialize logging before setup since setup can emit warnings to log 2010-07-23 20:47:56 -04:00
Paul J. Davis
9f941215d1 Slight change to worker booting message. 2010-07-22 14:53:59 -04:00
benoitc
a461817309 fix websocket with protocol 076. Fix from tom on irc. Thanks! 2010-06-24 16:20:48 +02:00
benoitc
06a4dc6881 fix one error in gunicorn_paster, global conf was ignored... While I'm
here change a little the behaviour of debug mode so we can still have
multiple workers in gunicorn :

- Don't preload app
- Set wsgi.multiprocess=False

rationnal is that when app isn't loaded it run in its own thread and
can't be evaluated by another process simultaneously. So setting
wsgi.multiprocess in this case sound good.
2010-06-22 13:10:49 +02:00
benoitc
6ca1a2398e there is no need to except, just reload in handle_hup method. 2010-06-17 17:09:22 +02:00
benoitc
8b10e33ecd just display listening info if addres has changed on HUP. 2010-06-17 16:48:55 +02:00
benoitc
92157fc503 old_listener is useless. 2010-06-17 16:43:38 +02:00
benoitc
7409535d69 no need to import socket 2010-06-17 16:33:27 +02:00
benoitc
a4fdb93757 just reload config and stay in the loop. 2010-06-17 15:55:45 +02:00
Paul Smith
48912484be Fix Arbiter bugs 2010-06-16 15:29:12 -04:00
benoitc
ebca25dddb make sure conf is available when spawning workers. Also since run
already manage_workers, no need to run this function in reload.
2010-06-16 11:38:35 +02:00
benoitc
05b6281e8d new HUP signal handling. Rather than reexecuting the app it mimic NGINX
behavior :

Configuration reload
Start the new worker processes with a new configuration
Gracefully shutdown the old worker processes

To reload gunicorn code use USR2 signal.
2010-06-16 11:10:06 +02:00
Paul J. Davis
12f8215e04 Avoid infinite loops spawning workers.
I noticed with preload that if a worker fails to boot the arbiter will
dutifully respawn it. Only to watch it die again. This patch makes it so
if a worker process exits before making it to the run loop the process
will exit with a special exit code. When the arbiter sees this flag it
will shutdown all processes assuming there is an unrecoverable error.
2010-05-25 19:54:33 -04:00
benoitc
4005614ced when_ready hook. Called just after the server is started 2010-05-23 00:45:31 +02:00
benoitc
f8fac58d73 some fixes discovered with pyflakes 2010-05-23 00:44:53 +02:00
benoitc
62540cffaa commit changes from @davisp + some fixes 2010-05-22 21:11:25 +02:00
benoitc
776b158683 add preload_app setting 2010-05-22 19:53:02 +02:00
Paul J. Davis
036f8b50d9 Major refactor of the configuration mechanics.
* All configuration and bootup is handled by the Application objects.

* There is now a strict ordering on the precedence of configuration
settings:

  1. Each option is given a default value of some sort in options.ini

  2. Any detectable framework configuration settings override the hard
     coded defaults for options. Currently, only Paster applications
     have support for this.

  3. Anything that is specified in a Gunicorn configuration file (by
     default gunicorn.conf.py) overrides what was possibly set by a
     framework specific configuration source.

  4. Anything specified on the command line reins supreme. The command
     line is the final authority on a given configuration option.
     Though, not all configuration options are available via command
     line.

* Configuration metadata is pulled from an options.ini. In the future I'll
use this to build the example gunicorn.conf.py and the config.rst file
in docs/site/config.rst.

I haven't tested the differences thoroughly. The next item on my agenda
is to figure out a way to start testing Gunicorn that doesn't make my
eyes bleed.
2010-05-19 13:39:37 -04:00
Benoit Chesneau
fdf8169a2c fix issue #57 and make sure target dir of pidfile exists. 2010-05-19 19:29:51 +02:00
Benoit Chesneau
a4f850cd73 fix reexec 2010-05-17 05:38:03 +02:00
Paul J. Davis
1a03c3f36e Bug preventing HUP completion.
Just a bit of cruft from the pidfile updates.
2010-05-16 14:02:55 -04:00
benoitc
87760fe750 put pidfile funcs in object on suggestion from davisp "but that's a
simple change"
2010-05-09 01:49:24 +02:00
benoitc
cbd91309fe don't use a property, instead use simple function. spotted by davisp:
"It seems too magical to me"
2010-05-09 01:13:32 +02:00
benoitc
5b2f98fca4 fix erros spotted by pyflakes 2010-04-22 19:41:29 +02:00
Paul J. Davis
0c935d06c7 Got the Sync and Eventlet workers running. 2010-04-15 21:20:17 -04:00
Paul J. Davis
51f1f22665 Refactoring worker code.
Also went through gunicorn.main lightly.
2010-04-15 20:08:28 -04:00