175 Commits

Author SHA1 Message Date
Edward Betts
fc64a43ec6 Correct spelling mistakes. 2018-02-19 22:00:41 +03:00
Berker Peksag
76eaa0805b Fix various warnings and errors reported by pylint 2018-01-11 09:59:31 +03:00
Andy Wilcox
32992a88f9 Avoid needlessly triggering non-false return from issetugid on MacOSX 2018-01-03 08:15:17 -08:00
YuppY
5953148573 Do not strip leading slash from path (#1511)
Fixes #1512
2017-12-28 11:32:47 +03:00
Juan Julián Merelo Guervós
6ba2ebe545 Make "failed to find application" more informative (#1648)
Co-Authored-By: Luis Liñán Villafranca <luislivilla@gmail.com>

Fixes #1647
2017-11-24 10:42:03 +03:00
Hasan Ramezani
81efa40da7 Improve parsing of 'unix://' addresses in parse_address (#1623) 2017-10-16 09:44:00 +03:00
Berker Peksag
f00fb441ca Remove unused variables 2017-07-12 18:07:16 +03:00
Benno Rice
72dd0199d7 Deal fully with deprecated functions.
If possible use a function based on inspect.signature to calculate the
arity.  If inspect.signature is not available fall back to getargspec. The
version based on inspect.signature looks like more code but is actually a
subset of what inspect.getfullargspec does.

html.escape is preferred over cgi.escape primarily because it defaults quote
to True. For this reason pass quote=True to cgi.escape when used.
2017-07-12 16:14:09 +03:00
Ed Morley
fbd151e984 Remove dead code found using vulture (#1469)
https://pypi.python.org/pypi/vulture

In particular the removal of `get_maxfd()` means the `resource` module
is no longer required (which is not available on Windows) and so helps
with #524.
2017-03-13 13:33:11 -07:00
Berker Peksag
31b8e48a78 Silence prospector warnings 2017-02-07 09:05:43 +03:00
Saeed Gharedaghi
ab444eed50 change __dict__ to vars function
Back gunicorn/argparse_compat.py gunicorn/six.py files changes

Back run_gunicorn.py file changes
2017-01-11 23:07:20 +03:00
Randall Leeds
bc5ae5d457 format boot tracebacks properly with reloader (#1415)
fix #1408
2016-12-23 10:56:07 -08:00
Patrick Browne
915c534eab feat(import_app): print original exception on AppImportError (#1334)
* feat(import_app): print original exception on AppImportError
2016-10-03 12:52:20 -07:00
benoitc
cb84e6ed11 initialize the group access list for a worker when initgroups is set
Allows the possibility to initialise the group access list when needed to separate privileges

fix #1287
2016-05-31 18:26:41 +02:00
benoitc
4d845f2ae4 fix pep8 warnings 2016-05-31 15:48:39 +02:00
benoitc
418f140445 remove file locking
This changes improve the binary upgrade behaviour using USR2:

- only one binary upgrade can happen at a time: the old arbiter needs to be
  killed to promote the new arbiter.
- if a new arbiter is already spawned, until one is killed USR2 has no action
- if a new arbiter has been spawned, the unix socket won't be unlinked
- until the old arbiter have been killed the newly created pidfile has the name
  <pidfile>.2 and the name Master.2 .

Note: there is no dialog between both arbiters to handle this features.
Instead they will supervise each others until one is killed. So isolation is
still guaranted.

fix #1267
2016-05-20 15:42:55 +02:00
benoitc
8a6748ee65 fix unix socket locking
This change add proper file locking to gunicorn. By default "gunicorn.lock" is created in the temporary directory when a unix socket is bound.  In case someone want to fix the lock file path or use multiple gunicorn instance the "--lock-file" setting can be used to set the path of this file.

fix #1259
2016-05-14 22:03:40 +02:00
benoitc
5bc13be79e rename util.is_fileobject to util.has_fileno
be more descriptive
2015-12-31 15:32:08 +01:00
benoitc
d55ef38c8a reuse util.is_fileobject
is_fileobject usgae was removed due to the use of the `tell` method check.
This change remove this check wich allows us to completely test if
fileno() is usable. Also it handle most of the exceptions around created by
breaking changes across Python versions. Hopefully we are good now.

fix #1174
2015-12-31 14:50:48 +01:00
Benoit Chesneau
6439c3ba7a don't check if a file is writable using os.stat
Some systems edisable like SELINUX disable some flags so ignore the possible
error while chowning a log file. The error will be raised later anyway.

fix #1171
2015-12-29 15:01:23 +01:00
Benoit Chesneau
c805bd2960 check auth before trying to own a file
fix #1157
2015-12-28 13:00:44 +01:00
benoitc
09e0d4c7fc encode fix test 2015-11-25 14:11:54 +01:00
benoitc
5f4ebd2eb2 don't return utf8 header in example
Since the updated RFC 7230 implys that new Headers Key and Value should be
sent as USASCII only don't try to test utf8 headers in examples.

We now only encode them to ascii. Gunicorn will fail if it's unable to encode
them letting the responsability to the application to correctly encode the
response. (we are just a gateway).

While i'm here simplify the code to not create an extra function only used at
one place.

NOTE: if anyone come to a better solution, i am happy to revisit it on the
next release.

fix #1151
2015-11-25 13:29:46 +01:00
Randall Leeds
18d2b92146 Simplify sendfile logic
A safe and reliable check for whether a file descriptor supports mmap
is to directly check if it is seekable. However, some seekable file
descriptors may also report a zero size when calling fstat. If there
is no content length specified for the response and it cannot be
determined from the file descriptor then it is not possible to know
what chunk size to send to the client. In this case, is it necessary
to fall back to unwinding the body by iteration.

The above conditions together reveal a straightforward and reliable
way to check for sendfile support. This patch modifies the Response
class to assert these conditions using a try/catch block as part of
a new, simplified sendfile method. This method returns False if it
is not possible to serve the response using sendfile. Otherwise, it
serves the response and returns True. By returning False when SSL is
in use, the code is made even simpler by removing the special support
for SSL, which is served well enough by the iteration protocol.

Fix #1038
2015-11-10 17:57:56 -08:00
Jochen Wersdörfer
338721ac56 encode http headers as latin1 RFC 2616 2015-08-29 11:16:58 +02:00
wong2
250d98f48a fix for review 2015-03-14 23:28:24 +08:00
wong2
d03891a470 reloader should survive SyntaxError 2015-03-11 20:46:44 +08:00
Berker Peksag
d376b6f78a Raise TypeError instead of AssertionError.
assert statements will be removed if you run Python
in optimized mode (e.g. with -O flag).
2015-02-23 00:35:47 +02:00
Berker Peksag
56e7d15fb8 Use more Pythonic style in gunicorn/. 2014-11-24 18:43:21 +02:00
Randall Leeds
fcba1a6c1c Merge pull request #770 from dwagon/731-umask
731 - Avoid creating world writable files
2014-11-17 19:03:01 -08:00
Collin Anderson
bfae0c91de sys.stderr.write -> print(msg, file=sys.stderr) 2014-09-16 15:38:56 -04:00
Collin Anderson
0d3045bb41 cleaned some code 2014-09-10 20:34:22 -04:00
Paul J. Davis
fc364cca7d Fix check for file-like objects
The `is_fileobject()` function in utils.py would break when the respones
was a wrapped `HTTPResponse`'s `raw` attribute. This just adds the
`IOError` exception type to the `is_fileobject()` function so that the
response can be streamed normally.

Fixes #805
2014-06-26 14:31:40 -05:00
Philipp Saveliev
dcb9464bbe fix HTTP-violating excess whitespace in write_error output 2014-06-03 03:05:27 +04:00
Dougal Scott
1b047a7e7b Avoid creating world writable files 2014-06-02 08:07:43 +10:00
benoitc
b7cbb59bbc remove useless code 2014-05-31 07:18:39 +02:00
benoitc
5f0a329b58 add fdevents module
This module add a new cross platform event poller to gunicorn. It allows
you to listen on different fds in an efficient manner.

On linux it's using epoll, bsd/darwin kqueue...
2014-04-13 08:59:47 +02:00
Berker Peksag
5c78adf9b9 Use email.utils.formatdate in gunicorn.util.http_date.
There is a also an open issue for CPython:

http://bugs.python.org/issue747320
2014-02-14 02:26:09 +02:00
Levi Gross
e0d2930887 Removed the <p> tag from the base file and added it to the template 2014-02-05 19:45:30 -05:00
Levi Gross
791ea6ae53 Invalid user supplied messages should be escaped HTML entity escaped. 2014-02-04 10:57:15 -05:00
benoitc
fdccb61616 use import_module instead of our own hack to import the module 2013-12-26 11:51:18 +01:00
benoitc
a397d90774 don't depend on entry point for internal classes.
We don't have to depend on entry points when loading suppoorted workers
nad extensions, instead use the absolute path to load the class.

fix #259
2013-12-26 11:33:05 +01:00
benoitc
f886d86b46 deprecate gunicorn_django 2013-08-27 21:17:33 +02:00
benoitc
dc97e54412 handle io.BytesIO object with file_wrapper
fix #595
2013-08-27 11:45:32 +02:00
benoitc
82099deff2 remove stupid change.
fix #519
2013-04-24 23:49:50 +02:00
benoitc
160db1f521 nginx way to set unix addresses 2013-04-23 16:29:31 +02:00
benoitc
532d1fffaf document the use of PYTHONUNBUFFERED in config 2013-04-23 16:23:46 +02:00
Graham Dumpleton
32e4cf14df Ensure that detaching from controlling terminals, but allow for redirection to files. 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
cc7f595adc Enable stdio inheritance.
Enable inheritance for stdio file descriptors in daemon mode. It allows
you in daemon mode to redirect the output to a file if needed.

By default in daemon mode gunicorn will close all file handle except if
you pass the "-R" options. In this cases STDIO will be preserved.

fix #309
2013-04-23 16:23:46 +02:00