mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
web_server: Restart in development mode only for source code changes
Helps: #2534. - When a module change is detected. Don't restart. Restart only when FreedomBox source code is changed. This prevents unwanted restarts when Python standard library is updated during an app's installation. - This will make functional tests more robust as during functional tests, freedombox service run in development mode. - This may lead to annoyances during development when we have to restart the service manually. This is unlikely but if it happens we can tweak the setting by maintaining the allow list of modules instead of deny list of modules. Tests: - Calibre installation which brings in new version of python standard library works without causing CherryPy to detect python module changes during 'apt-get install'. - Changing a source code file under the plinth/ directory leads to the service getting automatically restarted. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
This commit is contained in:
parent
409d011982
commit
d5f22a8755
@ -22,11 +22,9 @@ logger = logging.getLogger(__name__)
|
||||
# is removed from the system leading to change detected by CherryPy. The entire
|
||||
# service is then restarted if it is in development mode. This could cause a
|
||||
# temporary failure in requests served leading to failures in functional tests.
|
||||
# Workaround this by preventing auto-reloading for some python modules.
|
||||
MODULES_EXCLUDED_FROM_AUTORELOAD = [
|
||||
'iso3166',
|
||||
'psycopg2',
|
||||
]
|
||||
# Workaround this by preventing auto-reloading for all but FreedomBox's python
|
||||
# modules.
|
||||
AUTORELOAD_REGEX = r'^plinth'
|
||||
|
||||
_CUSTOM_STATIC_URL = '/custom/static'
|
||||
|
||||
@ -63,8 +61,6 @@ def init():
|
||||
"""Setup CherryPy server"""
|
||||
logger.info('Setting up CherryPy server')
|
||||
|
||||
exclude_modules = '|'.join(MODULES_EXCLUDED_FROM_AUTORELOAD)
|
||||
autoreload_regex = rf'^(?!(?:{exclude_modules})).+'
|
||||
# Configure default server
|
||||
cherrypy.config.update({
|
||||
'server.max_request_body_size': 0,
|
||||
@ -73,7 +69,7 @@ def init():
|
||||
'server.thread_pool': 10,
|
||||
# Avoid stating files once per second in production
|
||||
'engine.autoreload.on': cfg.develop,
|
||||
'engine.autoreload.match': autoreload_regex,
|
||||
'engine.autoreload.match': AUTORELOAD_REGEX,
|
||||
})
|
||||
|
||||
application = web_framework.get_wsgi_application()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user