def setup_server(): db_ver_int = utils.get_db_ver_int() listener.add_listener('system', on_system_msg) if db_ver_int > settings.local.version_int: logger.error('Database version is newer than server version', 'setup', db_version=db_ver_int, server_version=settings.local.version_int, ) exit(75) global db_setup db_setup = not settings.conf.mongodb_uri global server_upgrade server_upgrade = db_ver_int < settings.local.version_int if db_setup or server_upgrade: logger.info('Starting setup server', 'setup') if not db_setup: upgrade_database() settings.local.server_start.clear() thread = threading.Thread(target=server_thread) thread.daemon = True thread.start() setup_ready.wait() utils.set_db_ver(__version__)
def setup_server(): global setup_state last_error = time.time() - 24 while True: try: db_ver_int = utils.get_db_ver_int() break except: time.sleep(0.5) if time.time() - last_error > 30: last_error = time.time() logger.exception('Error connecting to mongodb server') listener.add_listener('system', on_system_msg) if db_ver_int > settings.local.version_int: logger.error( 'Database version is newer than server version', 'setup', db_version=db_ver_int, server_version=settings.local.version_int, ) exit(75) if not settings.conf.mongodb_uri: setup_state = 'setup' elif check_db_ver(db_ver_int): setup_state = 'upgrade' if setup_state: logger.info('Starting setup server', 'setup') if setup_state == 'upgrade': upgrade_database() settings.local.server_start.clear() thread = threading.Thread(target=server_thread) thread.daemon = True thread.start() setup_ready.wait() time.sleep(0.5) upgrade.database_clean_up() last_error = time.time() - 24 while True: try: utils.set_db_ver(__version__) break except: time.sleep(0.5) if time.time() - last_error > 30: last_error = time.time() logger.exception('Error connecting to mongodb server')
def setup_server(): global setup_state last_error = time.time() - 24 while True: try: db_ver_int = utils.get_db_ver_int() break except: time.sleep(0.5) if time.time() - last_error > 30: last_error = time.time() logger.exception('Error connecting to mongodb server') listener.add_listener('system', on_system_msg) if db_ver_int > settings.local.version_int: logger.error('Database version is newer than server version', 'setup', db_version=db_ver_int, server_version=settings.local.version_int, ) exit(75) if not settings.conf.mongodb_uri: setup_state = 'setup' elif check_db_ver(db_ver_int): setup_state = 'upgrade' if setup_state: logger.info('Starting setup server', 'setup') if setup_state == 'upgrade': upgrade_database() settings.local.server_start.clear() thread = threading.Thread(target=server_thread) thread.daemon = True thread.start() setup_ready.wait() time.sleep(1) upgrade.database_clean_up() last_error = time.time() - 24 while True: try: utils.set_db_ver(__version__) break except: time.sleep(0.5) if time.time() - last_error > 30: last_error = time.time() logger.exception('Error connecting to mongodb server')
def start_queue(): for cpu_priority in (LOW_CPU, NORMAL_CPU, HIGH_CPU): thread = threading.Thread(target=_runner_thread, args=( cpu_priority, thread_limits[cpu_priority], runner_queues[cpu_priority], )) thread.daemon = True thread.start() threading.Thread(target=_check_thread).start() listener.add_listener('queue', _on_msg)
def setup_host(): from pritunl import host collection = mongo.get_collection('settings') collection.update({ '_id': 'subscription', }, {'$setOnInsert': { 'active': None, 'plan': None, }}, upsert=True) host.init() listener.add_listener('hosts', _on_msg)
def setup_server(): last_error = time.time() - 24 while True: try: db_ver_int = utils.get_db_ver_int() break except pymongo.errors.ConnectionFailure: time.sleep(0.5) if time.time() - last_error > 30: last_error = time.time() logger.exception('Error connecting to mongodb server') listener.add_listener('system', on_system_msg) if db_ver_int > settings.local.version_int: logger.error( 'Database version is newer than server version', 'setup', db_version=db_ver_int, server_version=settings.local.version_int, ) exit(75) # Fix for replaced conf file in 0.10.x upgrade if db_ver_int < 10000000000004000 and not settings.conf.mongodb_uri: settings.conf.mongodb_uri = 'mongodb://localhost:27017/pritunl' settings.conf.commit() global db_setup db_setup = not settings.conf.mongodb_uri global server_upgrade server_upgrade = db_ver_int and db_ver_int < settings.local.version_int if db_setup or server_upgrade: logger.info('Starting setup server', 'setup') if not db_setup: upgrade_database() settings.local.server_start.clear() thread = threading.Thread(target=server_thread) thread.daemon = True thread.start() setup_ready.wait() utils.set_db_ver(__version__)
def setup_server(): last_error = time.time() - 24 while True: try: db_ver_int = utils.get_db_ver_int() break except pymongo.errors.ConnectionFailure: time.sleep(0.5) if time.time() - last_error > 30: last_error = time.time() logger.exception('Error connecting to mongodb server') listener.add_listener('system', on_system_msg) if db_ver_int > settings.local.version_int: logger.error('Database version is newer than server version', 'setup', db_version=db_ver_int, server_version=settings.local.version_int, ) exit(75) # Fix for replaced conf file in 0.10.x upgrade if db_ver_int < 10000000000004000 and not settings.conf.mongodb_uri: settings.conf.mongodb_uri = 'mongodb://localhost:27017/pritunl' settings.conf.commit() global db_setup db_setup = not settings.conf.mongodb_uri global server_upgrade server_upgrade = db_ver_int and db_ver_int < settings.local.version_int if db_setup or server_upgrade: logger.info('Starting setup server', 'setup') if not db_setup: upgrade_database() settings.local.server_start.clear() thread = threading.Thread(target=server_thread) thread.daemon = True thread.start() setup_ready.wait() utils.set_db_ver(__version__)
def setup_server(): db_ver_int = utils.get_db_ver_int() listener.add_listener('system', on_system_msg) if db_ver_int > settings.local.version_int: logger.error( 'Database version is newer than server version', 'setup', db_version=db_ver_int, server_version=settings.local.version_int, ) exit(75) # Fix for replaced conf file in 0.10.x upgrade if db_ver_int < 10000000000004000 and not settings.conf.mongodb_uri: settings.conf.mongodb_uri = 'mongodb://localhost:27017/pritunl' settings.conf.commit() global db_setup db_setup = not settings.conf.mongodb_uri global server_upgrade server_upgrade = db_ver_int and db_ver_int < settings.local.version_int if db_setup or server_upgrade: logger.info('Starting setup server', 'setup') if not db_setup: upgrade_database() settings.local.server_start.clear() thread = threading.Thread(target=server_thread) thread.daemon = True thread.start() setup_ready.wait() utils.set_db_ver(__version__)
def setup_server(): db_ver_int = utils.get_db_ver_int() listener.add_listener('system', on_system_msg) if db_ver_int > settings.local.version_int: logger.error('Database version is newer than server version', 'setup', db_version=db_ver_int, server_version=settings.local.version_int, ) exit(75) # Fix for replaced conf file in 0.10.x upgrade if db_ver_int < 100000000 and not settings.conf.mongodb_uri: settings.conf.mongodb_uri = 'mongodb://localhost:27017/pritunl' settings.conf.commit() global db_setup db_setup = not settings.conf.mongodb_uri global server_upgrade server_upgrade = db_ver_int and db_ver_int < settings.local.version_int if db_setup or server_upgrade: logger.info('Starting setup server', 'setup') if not db_setup: upgrade_database() settings.local.server_start.clear() thread = threading.Thread(target=server_thread) thread.daemon = True thread.start() setup_ready.wait() utils.set_db_ver(__version__)
def start_server(): listener.add_listener('servers', _on_msg)
def start_settings(): listener.add_listener('setting', settings.on_msg) _start_check_timer()
def setup_subscription(): listener.add_listener('subscription', _on_msg)
def setup_server_listeners(): from pritunl import clients listener.add_listener('port_forwarding', clients.on_port_forwarding) listener.add_listener('client', clients.on_client)
def start_instance(): listener.add_listener('instance', server.on_msg)
def start_server(): thread = threading.Thread(target=_server_check_thread) thread.daemon = True thread.start() listener.add_listener('servers', _on_msg)
def setup_port_forwarding(): from pritunl import clients listener.add_listener('port_forwarding', clients.on_port_forwarding)