Enable code live reload only in debug mode

This commit is contained in:
Julien Duponchelle 2015-01-26 09:51:29 +01:00
parent c409819382
commit 1bfb201368
2 changed files with 5 additions and 3 deletions

View File

@ -82,7 +82,7 @@ def parse_arguments():
parser.add_argument("-L", "--local", action="store_true", help="local mode (allow some insecure operations)") parser.add_argument("-L", "--local", action="store_true", help="local mode (allow some insecure operations)")
parser.add_argument("-A", "--allow", action="store_true", help="allow remote connections to local console ports") parser.add_argument("-A", "--allow", action="store_true", help="allow remote connections to local console ports")
parser.add_argument("-q", "--quiet", action="store_true", help="do not show logs on stdout") parser.add_argument("-q", "--quiet", action="store_true", help="do not show logs on stdout")
parser.add_argument("-d", "--debug", action="store_true", help="show debug logs") parser.add_argument("-d", "--debug", action="store_true", help="show debug logs and enable code live reload")
args = parser.parse_args() args = parser.parse_args()
config = Config.instance() config = Config.instance()
@ -94,6 +94,7 @@ def parse_arguments():
server_config["ssl"] = server_config.get("ssl", "true" if args.ssl else "false") server_config["ssl"] = server_config.get("ssl", "true" if args.ssl else "false")
server_config["certfile"] = server_config.get("certfile", args.certfile) server_config["certfile"] = server_config.get("certfile", args.certfile)
server_config["certkey"] = server_config.get("certkey", args.certkey) server_config["certkey"] = server_config.get("certkey", args.certkey)
server_config["debug"] = server_config.get("debug", "true" if args.debug else "false")
config.set_section_config("Server", server_config) config.set_section_config("Server", server_config)
return args return args

View File

@ -164,6 +164,7 @@ class Server:
self._loop.run_until_complete(self._run_application(app, ssl_context)) self._loop.run_until_complete(self._run_application(app, ssl_context))
self._signal_handling() self._signal_handling()
# FIXME: remove it in production or in tests if server_config["debug"] == "true":
self._loop.call_later(1, self._reload_hook) log.info("Code live reload is enabled, watching for file changes")
self._loop.call_later(1, self._reload_hook)
self._loop.run_forever() self._loop.run_forever()