def run_command(): logging.info(datetime.now().strftime('%B %d, %Y - %H:%M:%S %Z')) logging.info('Jet Bridge version {}'.format(VERSION)) if missing_options == settings.required_options_without_default: create_config() return elif len(missing_options) and len(missing_options) < len( settings.required_options_without_default): logging.info('Required options are not specified: {}'.format( ', '.join(missing_options))) return from jet_bridge.app import make_app app = make_app() app.listen(settings.PORT, settings.ADDRESS) address = 'localhost' if settings.ADDRESS == '0.0.0.0' else settings.ADDRESS url = 'http://{}:{}/'.format(address, settings.PORT) logging.info('Starting server at {}'.format(url)) if settings.DEBUG: logging.warning('Server is running in DEBUG mode') logging.info('Quit the server with CONTROL-C') try: session = Session() token, created = register_token(session) if not token: return if not is_token_activated(session): token = get_token(session) register_url = '{}api/register/?token={}'.format(url, token) logging.warning('[!] Your server token is not activated') logging.warning('[!] Token: {}'.format(token)) if settings.AUTO_OPEN_REGISTER and webbrowser.open(register_url): logging.warning( '[!] Activation page was opened in your browser - {}'. format(register_url)) except RequestException: logging.error('[!] Can\'t connect to Jet Admin API') logging.error('[!] Token verification failed') finally: session.close() tornado.ioloop.IOLoop.current().start()
def main(): args = sys.argv[1:] if 'ARGS' in os.environ: args = os.environ['ARGS'].split(' ') logger.info(datetime.now().strftime('%B %d, %Y - %H:%M:%S %Z')) logger.info('Jet Bridge version {}'.format(VERSION)) if (len(args) >= 1 and args[0] == 'config' ) or missing_options == required_options_without_default: from jet_bridge.utils.create_config import create_config create_config(missing_options == required_options_without_default) return elif len(missing_options) and len(missing_options) < len( required_options_without_default): logger.info('Required options are not specified: {}'.format( ', '.join(missing_options))) return address = 'localhost' if settings.ADDRESS == '0.0.0.0' else settings.ADDRESS url = 'http://{}:{}/'.format(address, settings.PORT) api_url = '{}api/'.format(url) if len(args) >= 1: if args[0] == 'check_token': check_token_command(api_url) return database_connect() from jet_bridge.app import make_app app = make_app() server = HTTPServer(app) server.bind(settings.PORT, settings.ADDRESS) server.start(settings.WORKERS if not settings.DEBUG else 1) if settings.WORKERS > 1 and settings.DEBUG: logger.warning('Multiple workers are not supported in DEBUG mode') logger.info('Starting server at {}'.format(url)) if settings.DEBUG: logger.warning('Server is running in DEBUG mode') logger.info('Quit the server with CONTROL-C') check_token_command(api_url) IOLoop.current().start()
def main(): args = sys.argv[1:] if 'ARGS' in os.environ: args = os.environ['ARGS'].split(' ') logger.info(datetime.now().strftime('%B %d, %Y - %H:%M:%S %Z')) logger.info('Jet Bridge version {}'.format(VERSION)) if (len(args) >= 1 and args[0] == 'config') or missing_options == required_options_without_default: create_config(missing_options == required_options_without_default) return elif len(missing_options) and len(missing_options) < len(required_options_without_default): logger.info('Required options are not specified: {}'.format(', '.join(missing_options))) return if not engine_url: raise Exception('Database configuration is not set') address = 'localhost' if settings.ADDRESS == '0.0.0.0' else settings.ADDRESS url = 'http://{}:{}/'.format(address, settings.PORT) api_url = '{}api/'.format(url) if len(args) >= 1: if args[0] == 'check_token': check_token_command(api_url) return from jet_bridge.app import make_app app = make_app() app.listen(settings.PORT, settings.ADDRESS) logger.info('Starting server at {}'.format(url)) if settings.DEBUG: logger.warning('Server is running in DEBUG mode') logger.info('Quit the server with CONTROL-C') check_token_command(api_url) tornado.ioloop.IOLoop.current().start()
def run_command(): from jet_bridge.app import make_app app = make_app() app.listen(settings.PORT, settings.ADDRESS) address = 'localhost' if settings.ADDRESS == '0.0.0.0' else settings.ADDRESS url = 'http://{}:{}/'.format(address, settings.PORT) logging.info('Starting server at {}'.format(url)) if settings.DEBUG: logging.warning('Server is running in DEBUG mode') logging.info('Quit the server with CONTROL-C') try: session = Session() token, created = register_token(session) if not token: return if not is_token_activated(session): token = get_token(session) register_url = '{}api/register/?token={}'.format(url, token) logging.warning('[!] Your server token is not activated') logging.warning('[!] Token: {}'.format(token)) if settings.AUTO_OPEN_REGISTER and webbrowser.open(register_url): logging.warning('[!] Activation page was opened in your browser - {}'.format(register_url)) except RequestException: logging.error('[!] Can\'t connect to Jet Admin API') logging.error('[!] Token verification failed') finally: session.close() tornado.ioloop.IOLoop.current().start()