def migrated_db(migration_manager_port): port = migration_manager_port try: r = requests.get(f'http://localhost:{port}') status = r.json() except requests.exceptions.RequestException: log(f'Could not connect to migration manager on port [{port}]') return None return status["migrated"]
app.cfg = cfg def migrated_db(migration_manager_port): port = migration_manager_port try: r = requests.get(f'http://localhost:{port}') status = r.json() except requests.exceptions.RequestException: log(f'Could not connect to migration manager on port [{port}]') return None return status["migrated"] # Before serving, ask migration_manager whether the DB is ready log('Verifying database migration status') port = cfg['ports.migration_manager'] timeout = 1 while not migrated_db(port): log(f'Database not migrated, or could not verify; trying again in {timeout}s' ) time.sleep(timeout) timeout = max(timeout * 2, 30) port = cfg['ports.app_internal'] + (env.process or 0) app.listen(port, xheaders=True) log(f'Listening on port {port}') tornado.ioloop.IOLoop.current().start()
def migrated_db(migration_manager_port): port = migration_manager_port try: r = requests.get(f"http://localhost:{port}") status = r.json() except requests.exceptions.RequestException: log(f"Could not connect to migration manager on port [{port}]") return None return status["migrated"] # Before creating the app, ask migration_manager whether the DB is ready log("Verifying database migration status") port = cfg["ports.migration_manager"] timeout = 1 while not migrated_db(port): log(f"Database not migrated, or could not verify; trying again in {timeout}s") time.sleep(timeout) timeout = min(timeout * 2, 30) module, app_factory = app_factory.rsplit(".", 1) app_factory = getattr(importlib.import_module(module), app_factory) app = app_factory( cfg, baselayer_handlers, baselayer_settings,