bind the reload of the webserver on the debug settings

fix #1163
This commit is contained in:
Oskar Hahn 2014-05-17 14:43:16 +02:00 committed by Norman Jäckel
parent bf8bb31cdb
commit 22bacd1054
4 changed files with 9 additions and 11 deletions

View File

@ -51,6 +51,7 @@ Other:
- Used jsonfield as required package. Removed jsonfield code. - Used jsonfield as required package. Removed jsonfield code.
- Added new package backports.ssl_match_hostname for portable build script. - Added new package backports.ssl_match_hostname for portable build script.
- Use app "django-ckeditor-updated" to render WYSIWYG HTML editors - Use app "django-ckeditor-updated" to render WYSIWYG HTML editors
- Only reload the webserver in debug-mode.
Version 1.5.1 (2014-03-31) Version 1.5.1 (2014-03-31)

View File

@ -104,10 +104,7 @@ def parse_args():
'--start-browser', '--start-browser',
action='store_true', action='store_true',
help='Launch the default web browser and open the webinterface.') help='Launch the default web browser and open the webinterface.')
subcommand_runserver.add_argument(
'--no-reload',
action='store_true',
help='Do not reload the webserver if source code changes.')
subcommand_runserver.set_defaults(callback=runserver) subcommand_runserver.set_defaults(callback=runserver)
# Subcommand syncdb # Subcommand syncdb
@ -221,11 +218,10 @@ def start(settings, args):
ensure_settings(settings, args) ensure_settings(settings, args)
syncdb(settings, args) syncdb(settings, args)
args.start_browser = not args.no_browser args.start_browser = not args.no_browser
args.no_reload = False runserver(settings, args, block_reload=True)
runserver(settings, args)
def runserver(settings, args): def runserver(settings, args, block_reload=False):
""" """
Runs tornado webserver. Runs the function start_browser if the respective Runs tornado webserver. Runs the function start_browser if the respective
argument is given. argument is given.
@ -238,7 +234,7 @@ def runserver(settings, args):
# Now the settings is available and the function can be imported. # Now the settings is available and the function can be imported.
from openslides.utils.tornado_webserver import run_tornado from openslides.utils.tornado_webserver import run_tornado
run_tornado(args.address, port, not args.no_reload) run_tornado(args.address, port, block_reload)
def syncdb(settings, args): def syncdb(settings, args):

View File

@ -68,7 +68,7 @@ class ProjectorSocketHandler(SockJSConnection):
waiter.send(data) waiter.send(data)
def run_tornado(addr, port, reload=False): def run_tornado(addr, port, block_reload=False):
# Don't try to read the command line args from openslides # Don't try to read the command line args from openslides
parse_command_line(args=[]) parse_command_line(args=[])
@ -92,7 +92,8 @@ def run_tornado(addr, port, reload=False):
('.*', FallbackHandler, dict(fallback=app))] ('.*', FallbackHandler, dict(fallback=app))]
# Start the application # Start the application
tornado_app = Application(projectpr_socket_js_router.urls + chatbox_socket_js_router.urls + other_urls, debug=reload) debug = False if block_reload else settings.DEBUG
tornado_app = Application(projectpr_socket_js_router.urls + chatbox_socket_js_router.urls + other_urls, debug=debug)
server = HTTPServer(tornado_app) server = HTTPServer(tornado_app)
server.listen(port=port, address=addr) server.listen(port=port, address=addr)
IOLoop.instance().start() IOLoop.instance().start()

View File

@ -117,7 +117,7 @@ class TestOtherFunctions(TestCase):
mock_args = MagicMock() mock_args = MagicMock()
start(settings=None, args=mock_args) start(settings=None, args=mock_args)
self.assertTrue(mock_syncdb.called) self.assertTrue(mock_syncdb.called)
mock_runserver.assert_called_with(None, mock_args) mock_runserver.assert_called_with(None, mock_args, block_reload=True)
@patch('openslides.__main__.get_port') @patch('openslides.__main__.get_port')
@patch('openslides.utils.tornado_webserver.run_tornado') @patch('openslides.utils.tornado_webserver.run_tornado')