def appstart(keepalive=False): logger.info("Fuel-Web {0} SHA: {1}\nFuel SHA: {2}".format( settings.PRODUCT_VERSION, settings.COMMIT_SHA, settings.FUEL_COMMIT_SHA )) if not get_engine().dialect.has_table(get_engine().connect(), "nodes"): logger.error( "Database tables not created. Try './manage.py syncdb' first" ) sys.exit(1) app = build_app() from nailgun.rpc import threaded from nailgun.keepalive import keep_alive from nailgun.plugin.thread import PluginThread plugin_thread = PluginThread() logger.info("Running plugin processing thread...") plugin_thread.start() if keepalive: logger.info("Running KeepAlive watcher...") keep_alive.start() if not settings.FAKE_TASKS: if not keep_alive.is_alive() \ and not settings.FAKE_TASKS_AMQP: logger.info("Running KeepAlive watcher...") keep_alive.start() rpc_process = threaded.RPCKombuThread() logger.info("Running RPC consumer...") rpc_process.start() logger.info("Running WSGI app...") wsgifunc = build_middleware(app.wsgifunc) run_server(wsgifunc, (settings.LISTEN_ADDRESS, int(settings.LISTEN_PORT))) logger.info("Stopping WSGI app...") if plugin_thread.is_alive(): logger.info("Stopping PluginThread...") plugin_thread.soft_stop() if keep_alive.is_alive(): logger.info("Stopping KeepAlive watcher...") keep_alive.join() if not settings.FAKE_TASKS: logger.info("Stopping RPC consumer...") rpc_process.join() logger.info("Done")