mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Fix validate_reload by returning the validated value (#1378)
* Fix validate_reload by returning the validated value When '--reload=RELOADER_TYPE' was implemented, `validate_reload()` was added but in one of the last refactorings, it lost the return statement at the end of the function. As a result, the '--reload' config value was totally broken. This resolves the issue by adding the missing return. * Fix tests by changing --reload to always require an argument - '--reload' always requires an argument now - Added 'auto' as the default value for '--reload'
This commit is contained in:
parent
07f62e26f3
commit
6eb01409da
@ -256,7 +256,7 @@ reload
|
||||
~~~~~~
|
||||
|
||||
* ``--reload RELOADER_TYPE``
|
||||
* ``None``
|
||||
* ``off``
|
||||
|
||||
Restart workers when code changes.
|
||||
|
||||
@ -270,8 +270,8 @@ application code or the reload will not work as designed.
|
||||
When using this option, you can optionally specify whether you would
|
||||
like to use file system polling or the kernel's inotify API to watch
|
||||
for changes. Generally, inotify should be preferred if available
|
||||
because it consumes less system resources. If no preference is given,
|
||||
inotify will attempted with a fallback to FS polling.
|
||||
because it consumes less system resources. The default behavior (auto)
|
||||
is to attempt inotify with a fallback to FS polling.
|
||||
|
||||
Note: In order to use the inotify reloader, you must have the 'inotify'
|
||||
package installed.
|
||||
|
||||
@ -492,15 +492,17 @@ def validate_hostport(val):
|
||||
|
||||
def validate_reloader(val):
|
||||
if val is None:
|
||||
val = 'default'
|
||||
val = 'auto'
|
||||
|
||||
choices = ['poll', 'inotify', 'default']
|
||||
choices = ['auto', 'poll', 'inotify', 'off']
|
||||
|
||||
if val not in choices:
|
||||
raise ConfigError(
|
||||
'Invalid reloader type. Must be one of: %s' % choices
|
||||
)
|
||||
|
||||
return val
|
||||
|
||||
|
||||
def get_default_config_file():
|
||||
config_path = os.path.join(os.path.abspath(os.getcwd()),
|
||||
@ -820,9 +822,7 @@ class Reload(Setting):
|
||||
section = 'Debugging'
|
||||
cli = ['--reload']
|
||||
validator = validate_reloader
|
||||
nargs = '?'
|
||||
const = 'default'
|
||||
default = None
|
||||
default = 'off'
|
||||
meta = 'RELOADER_TYPE'
|
||||
|
||||
desc = '''\
|
||||
@ -838,8 +838,8 @@ class Reload(Setting):
|
||||
When using this option, you can optionally specify whether you would
|
||||
like to use file system polling or the kernel's inotify API to watch
|
||||
for changes. Generally, inotify should be preferred if available
|
||||
because it consumes less system resources. If no preference is given,
|
||||
inotify will attempted with a fallback to FS polling.
|
||||
because it consumes less system resources. The default behavior (auto)
|
||||
is to attempt inotify with a fallback to FS polling.
|
||||
|
||||
Note: In order to use the inotify reloader, you must have the 'inotify'
|
||||
package installed.
|
||||
|
||||
@ -115,7 +115,7 @@ class Worker(object):
|
||||
self.load_wsgi()
|
||||
|
||||
# start the reloader
|
||||
if self.cfg.reload:
|
||||
if self.cfg.reload and self.cfg.reload != 'off':
|
||||
def changed(fname):
|
||||
self.log.info("Worker reloading: %s modified", fname)
|
||||
self.alive = False
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user