Example #1
0
    def run(self):
        #cherrypy.engine.unsubscribe('graceful', cherrypy.log.reopen_files)

        logging.config.dictConfig(OmniDB.settings.LOGGING)
        #cherrypy.log.error_log.propagate = False
        cherrypy.log.access_log.propagate = False
        self.mount_static(OmniDB.settings.STATIC_URL,
                          OmniDB.settings.STATIC_ROOT)

        cherrypy.tree.graft(WSGIHandler())

        port = listening_port
        num_attempts = 0

        print('''Starting OmniDB server...''')
        logger.info('''Starting OmniDB server...''')
        print('''Checking port availability...''')
        logger.info('''Checking port availability...''')

        while not check_port(port) or num_attempts >= 20:
            print("Port {0} is busy, trying another port...".format(port))
            logger.info(
                "Port {0} is busy, trying another port...".format(port))
            port = random.randint(1025, 32676)
            num_attempts = num_attempts + 1

        if num_attempts < 20:
            cherrypy.config.update({
                'server.socket_host': self.HOST,
                'server.socket_port': port,
                'engine.autoreload_on': False,
                'log.screen': False,
                'log.access_file': '',
                'log.error_file': ''
            })

            print("Starting server {0} at http://127.0.0.1:{1}.".format(
                OmniDB.settings.OMNIDB_VERSION, str(port)))
            logger.info("Starting server {0} at http://127.0.0.1:{1}.".format(
                OmniDB.settings.OMNIDB_VERSION, str(port)))

            # Startup
            startup.startup_procedure()

            cherrypy.engine.start()

            init_browser(port)
            cherrypy.engine.exit()
        else:
            print('Tried 20 different ports without success, closing...')
            logger.info('Tried 20 different ports without success, closing...')
Example #2
0
    def run(self,parameters):
        #cherrypy.engine.unsubscribe('graceful', cherrypy.log.reopen_files)

        logging.config.dictConfig(OmniDB.settings.LOGGING)
        #cherrypy.log.error_log.propagate = False
        cherrypy.log.access_log.propagate = False
        self.mount_static(OmniDB.settings.STATIC_URL, OmniDB.settings.STATIC_ROOT)

        cherrypy.tree.graft(WSGIHandler())

        port = parameters['listening_port']
        num_attempts = 0

        print('''Starting OmniDB server...''',flush=True)
        logger.info('''Starting OmniDB server...''')
        print('''Checking port availability...''',flush=True)
        logger.info('''Checking port availability...''')

        while not check_port(port) or num_attempts >= 20:
            print("Port {0} is busy, trying another port...".format(port),flush=True)
            logger.info("Port {0} is busy, trying another port...".format(port))
            port = random.randint(1025,32676)
            num_attempts = num_attempts + 1

        if num_attempts < 20:

            v_cherrypy_config = {
                'server.socket_host': parameters['listening_address'],
                'server.socket_port': port,
                'engine.autoreload_on': False,
                'log.screen': False,
                'log.access_file': '',
                'log.error_file': ''
            }

            if parameters['is_ssl']:
                import ssl
                ssl_ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
                ssl_ctx.options |= ssl.OP_NO_TLSv1
                ssl_ctx.options |= ssl.OP_NO_TLSv1_1
                ssl_ctx.load_cert_chain(parameters['ssl_certificate_file'],
                                       parameters['ssl_key_file'])
                v_cherrypy_config['server.ssl_module'] = 'builtin'
                v_cherrypy_config['server.ssl_certificate'] = parameters['ssl_certificate_file']
                v_cherrypy_config['server.ssl_private_key'] = parameters['ssl_key_file']
                v_cherrypy_config['server.ssl_context'] = ssl_ctx

            cherrypy.config.update(v_cherrypy_config)

            print ("Starting server {0} at {1}:{2}.".format(OmniDB.settings.OMNIDB_VERSION,parameters['listening_address'],str(port)),flush=True)
            logger.info("Starting server {0} at {1}:{2}.".format(OmniDB.settings.OMNIDB_VERSION,parameters['listening_address'],str(port)))

            # Startup
            startup.startup_procedure()

            cherrypy.engine.start()

            if not app_version:
                print ("Open OmniDB in your favorite browser",flush=True)
                if platform.system() != 'Windows':
                    print ("Press Ctrl+C to exit",flush=True)
            else:
                #Sending response to electron app
                print ("http://localhost:{0}/login/?user=admin&pwd=admin&token={1}".format(str(port),OmniDB.custom_settings.APP_TOKEN),flush=True)


            cherrypy.engine.block()
            cherrypy.engine.exit()
        else:
            print('Tried 20 different ports without success, closing...',flush=True)
            logger.info('Tried 20 different ports without success, closing...')
Example #3
0
    def run(self, parameters):
        #cherrypy.engine.unsubscribe('graceful', cherrypy.log.reopen_files)

        logging.config.dictConfig(OmniDB.settings.LOGGING)
        #cherrypy.log.error_log.propagate = False
        cherrypy.log.access_log.propagate = False
        self.mount_static(OmniDB.settings.STATIC_URL,
                          OmniDB.settings.STATIC_ROOT)

        cherrypy.tree.graft(WSGIHandler())

        port = parameters['listening_port']
        num_attempts = 0

        print('''Starting OmniDB server...''')
        logger.info('''Starting OmniDB server...''')
        print('''Checking port availability...''')
        logger.info('''Checking port availability...''')

        while not check_port(port) or num_attempts >= 20:
            print("Port {0} is busy, trying another port...".format(port))
            logger.info(
                "Port {0} is busy, trying another port...".format(port))
            port = random.randint(1025, 32676)
            num_attempts = num_attempts + 1

        if num_attempts < 20:

            v_cherrypy_config = {
                'server.socket_host': parameters['listening_address'],
                'server.socket_port': port,
                'engine.autoreload_on': False,
                'log.screen': False,
                'log.access_file': '',
                'log.error_file': ''
            }

            if parameters['is_ssl']:
                v_cherrypy_config['server.ssl_module'] = 'builtin'
                v_cherrypy_config['server.ssl_certificate'] = parameters[
                    'ssl_certificate_file']
                v_cherrypy_config['server.ssl_private_key'] = parameters[
                    'ssl_key_file']

            cherrypy.config.update(v_cherrypy_config)

            print("Starting server {0} at {1}:{2}.".format(
                OmniDB.settings.OMNIDB_VERSION,
                parameters['listening_address'], str(port)))
            logger.info("Starting server {0} at {1}:{2}.".format(
                OmniDB.settings.OMNIDB_VERSION,
                parameters['listening_address'], str(port)))

            # Startup
            startup.startup_procedure()

            cherrypy.engine.start()

            print("Open OmniDB in your favorite browser")
            if platform.system() != 'Windows':
                print("Press Ctrl+C to exit")

            cherrypy.engine.block()
            cherrypy.engine.exit()
        else:
            print('Tried 20 different ports without success, closing...')
            logger.info('Tried 20 different ports without success, closing...')
Example #4
0
    def run(self, parameters):
        #cherrypy.engine.unsubscribe('graceful', cherrypy.log.reopen_files)

        logging.config.dictConfig(OmniDB.settings.LOGGING)
        #cherrypy.log.error_log.propagate = False
        cherrypy.log.access_log.propagate = False
        self.mount_static(OmniDB.settings.STATIC_URL,
                          OmniDB.settings.STATIC_ROOT)

        cherrypy.tree.graft(WSGIHandler())

        port = parameters['listening_port']
        num_attempts = 0

        print('''Starting OmniDB server...''', flush=True)
        logger.info('''Starting OmniDB server...''')
        print('''Checking port availability...''', flush=True)
        logger.info('''Checking port availability...''')

        while not check_port(port) or num_attempts >= 20:
            print("Port {0} is busy, trying another port...".format(port),
                  flush=True)
            logger.info(
                "Port {0} is busy, trying another port...".format(port))
            port = random.randint(1025, 32676)
            num_attempts = num_attempts + 1

        if num_attempts < 20:

            v_cherrypy_config = {
                'server.socket_host': parameters['listening_address'],
                'server.socket_port': port,
                'engine.autoreload_on': False,
                'log.screen': False,
                'log.access_file': '',
                'log.error_file': ''
            }

            if parameters['is_ssl']:
                import ssl
                ssl_ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
                ssl_ctx.options |= ssl.OP_NO_TLSv1
                ssl_ctx.options |= ssl.OP_NO_TLSv1_1
                ssl_ctx.load_cert_chain(parameters['ssl_certificate_file'],
                                        parameters['ssl_key_file'])
                v_cherrypy_config['server.ssl_module'] = 'builtin'
                v_cherrypy_config['server.ssl_certificate'] = parameters[
                    'ssl_certificate_file']
                v_cherrypy_config['server.ssl_private_key'] = parameters[
                    'ssl_key_file']
                v_cherrypy_config['server.ssl_context'] = ssl_ctx

            cherrypy.config.update(v_cherrypy_config)

            print("Starting server {0} at {1}:{2}.".format(
                OmniDB.settings.OMNIDB_VERSION,
                parameters['listening_address'], str(port)),
                  flush=True)
            logger.info("Starting server {0} at {1}:{2}.".format(
                OmniDB.settings.OMNIDB_VERSION,
                parameters['listening_address'], str(port)))

            # Startup
            startup.startup_procedure()

            cherrypy.engine.start()

            if not app_version:
                print("Open OmniDB in your favorite browser", flush=True)
                if platform.system() != 'Windows':
                    print("Press Ctrl+C to exit", flush=True)
            else:
                #Sending response to electron app
                print(
                    "http://localhost:{0}/login/?user=admin&pwd=admin&token={1}"
                    .format(str(port), OmniDB.custom_settings.APP_TOKEN),
                    flush=True)

            cherrypy.engine.block()
            cherrypy.engine.exit()
        else:
            print('Tried 20 different ports without success, closing...',
                  flush=True)
            logger.info('Tried 20 different ports without success, closing...')