Ejemplo n.º 1
0
    def start(self) -> None:
        if self.started:
            return

        configure_log_levels()
        load_configuration()
        self.factory = processfactory.get_process_factory()
        self.factory.initialize()
        # Ensure Qgis is initialized
        self.factory.start_qgis() 
        self.started = True
Ejemplo n.º 2
0
    def start(self) -> None:
        if self.started:
            return

        configure_log_levels()
        load_configuration()
        self.factory = processfactory.get_process_factory()
        self.factory.initialize()

        # Get cachemanager ATFER loading configuration
        from pyqgiswps.qgscache.cachemanager import cacheservice
        self.cachemanager = cacheservice

        # Ensure Qgis is initialized
        self.factory.start_qgis()
        self.started = True
Ejemplo n.º 3
0
def run_server(port, address=None, user=None):
    """ Run the server
    """
    from tornado.httpserver import HTTPServer

    if user:
        setuid(user)

    kwargs = {}

    # Setup ssl config
    if confservice.getboolean('server', 'ssl'):
        LOGGER.info("SSL enabled")
        kwargs['ssl_options'] = create_ssl_options()

    # Allow x-forward headers
    kwargs['xheaders'] = True

    # Run
    LOGGER.info("Running WPS server on port %s:%s", address, port)

    from pyqgiswps.executors import processfactory

    pr_factory = processfactory.get_process_factory()
    processes = pr_factory.initialize(True)

    max_buffer_size = get_size_bytes(confservice.get('server',
                                                     'maxbuffersize'))

    application = Application(processes)
    server = HTTPServer(application, max_buffer_size=max_buffer_size, **kwargs)
    server.listen(port, address=address)

    # Setup the supervisor timeout killer
    pr_factory.start_supervisor()

    try:
        loop = asyncio.get_event_loop()
        loop.add_signal_handler(signal.SIGINT, loop.stop)
        loop.add_signal_handler(signal.SIGTERM, loop.stop)
        LOGGER.info("WPS Server ready")
        loop.run_forever()
    except (KeyboardInterrupt, SystemExit):
        LOGGER.info("Server interrupted")
    finally:
        application.terminate()
        pr_factory.terminate()
Ejemplo n.º 4
0
def run_server(port, address=None, user=None):
    """ Run the server
    """
    import traceback
    from tornado.httpserver import HTTPServer

    if user:
        setuid(user)

    # Run
    LOGGER.info("Running WPS server %s on port %s:%s", __version__, address,
                port)

    from pyqgiswps.executors import processfactory

    pr_factory = processfactory.get_process_factory()
    pr_factory.initialize()

    max_buffer_size = get_size_bytes(confservice.get('server',
                                                     'maxbuffersize'))

    application = Application()
    server = HTTPServer(application, max_buffer_size=max_buffer_size)
    server.listen(port, address=address)

    # Setup the supervisor timeout killer
    pr_factory.start_supervisor()

    try:
        loop = asyncio.get_event_loop()
        loop.add_signal_handler(signal.SIGINT, loop.stop)
        loop.add_signal_handler(signal.SIGTERM, loop.stop)
        LOGGER.info("WPS Server ready")
        loop.run_forever()
    except (KeyboardInterrupt, SystemExit) as e:
        LOGGER.info("Server interrupted")
    finally:
        application.terminate()
        pr_factory.terminate()
Ejemplo n.º 5
0
 def get_processes(self):
     return get_process_factory()._create_qgis_processes()