Implement watching static files

This commit is contained in:
Bálint Bokros 2017-12-11 13:34:08 +01:00
parent c1f867f97c
commit 642ca7f54c
2 changed files with 22 additions and 0 deletions

19
lib/debug.py Normal file
View File

@ -0,0 +1,19 @@
from glob import iglob as glob
from itertools import chain
from tornado.autoreload import watch
# yo dawg, we heard you like generators, so now you can generate generators
# with generators
def _static_files():
return chain.from_iterable(
glob(pattern) for pattern in (
'static/*.js', 'static/*.css', 'templates/*htm?'
)
)
def watch_static_files():
for file in _static_files():
watch(file)

View File

@ -7,6 +7,7 @@ from tornado.web import Application
from tornado.ioloop import IOLoop
from config import WEB_PORT
import debug
from handlers import MainHandler, ZMQWebSocketHandler, LoginWebappHandler
import ui_modules
@ -23,6 +24,7 @@ if __name__ == '__main__':
ui_modules=ui_modules,
autoreload=True
)
application.listen(WEB_PORT)
logging.getLogger().setLevel(logging.DEBUG)
logging.debug('Python version: {}'.format(sys.version[:5]))
@ -30,4 +32,5 @@ if __name__ == '__main__':
logging.debug('ZeroMQ version: {}'.format(zmq.zmq_version()))
logging.debug('PyZMQ version: {}'.format(zmq.pyzmq_version()))
logging.info('Tornado application listening on port {}'.format(WEB_PORT))
debug.watch_static_files()
IOLoop.instance().start()