def web(wait): """ Serve the application If the database doesn't already exist it will be created. """ settings = Settings(sender_cls='app.worker.Sender') print(settings.to_string(True), flush=True) setup_logging(settings) logger.info('waiting for elasticsearch and redis to come up...') # give es a chance to come up fully, this just prevents lots of es errors, create_indices is itself lenient # skip wait as es and redis are generally already up and delay is causing missed requests # wait and sleep(4) _check_services_ready(settings) _elasticsearch_setup(settings) logger.info('starting server...') asyncio.get_event_loop().close() asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) loop = asyncio.get_event_loop() app = create_app(loop, settings) run_app(app, port=8000, loop=loop, print=lambda v: None, access_log=None)