Example #1
0
    def start(self):
        '''
        start the server
        '''
        LOGGER.info("starting OMServer Process")
        config = OMServerConfig()
        loc = config.location
        port = config.port
        key = config.private_key
        cert = config.pub_key
        if not (os.path.isfile(key) and os.path.isfile(cert)):
            raise IOError, "certificate '%s' and/or key '%s' not found" % (
                cert, key)
        try:
            self.server = VerifyingServerSSL((loc, port), key, cert)
        except socket.error:
            LOGGER.error('Unable to start the server.' +
                         (' Port %d is in use' % port) +
                         ' (Perhaps openmolar server is already running?)')
            return

        if loc == "":
            readable_loc = "on all interfaces"
        else:
            readable_loc = loc
        LOGGER.info("listening for ssl connections %s port %d" %
                    (readable_loc, port))
        LOGGER.debug("using cert %s" % cert)
        LOGGER.debug("using key %s" % key)

        # daemonise the process and write to /var/run
        self.start_(stderr=logger.LOCATION)

        self.server.register_instance(PermissionDispatcher())
        for manager, hash in config.managers:
            self.server.add_user(manager, hash)

        server_thread = threading.Thread(target=self.server.serve_forever)
        server_thread.start()
Example #2
0
    def start(self):
        '''
        start the server
        '''
        LOGGER.info("starting OMServer Process")
        config = OMServerConfig()
        loc = config.location
        port = config.port
        key = config.private_key
        cert = config.pub_key
        if not (os.path.isfile(key) and os.path.isfile(cert)):
            raise IOError, "certificate '%s' and/or key '%s' not found"% (
                                                                cert, key)
        try:
            self.server = VerifyingServerSSL((loc, port), key, cert)
        except socket.error:
            LOGGER.error('Unable to start the server.' +
                (' Port %d is in use' % port ) +
                ' (Perhaps openmolar server is already running?)')
            return

        if loc == "":
            readable_loc = "on all interfaces"
        else:
            readable_loc = loc
        LOGGER.info(
            "listening for ssl connections %s port %d"% (readable_loc, port))
        LOGGER.debug("using cert %s"% cert)
        LOGGER.debug("using key %s"% key)

        # daemonise the process and write to /var/run
        self.start_(stderr=logger.LOCATION)

        self.server.register_instance(PermissionDispatcher())
        for manager, hash in config.managers:
            self.server.add_user(manager, hash)

        server_thread = threading.Thread(target=self.server.serve_forever)
        server_thread.start()
Example #3
0
class OMServer(Service):

    server = None
    '''
    A pointer to the :doc:`VerifyingServerSSL`
    '''
    def __init__(self, verbose=False):
        if verbose:
            LOGGER.setLevel(logging.DEBUG)
            LOGGER.debug("logging in verbose mode")
            import lib_openmolar
            LOGGER.debug(
                "using module lib_openmolar from %s"% lib_openmolar.__file__)
        else:
            LOGGER.setLevel(logging.INFO)

    def start(self):
        '''
        start the server
        '''
        LOGGER.info("starting OMServer Process")
        config = OMServerConfig()
        loc = config.location
        port = config.port
        key = config.private_key
        cert = config.pub_key
        if not (os.path.isfile(key) and os.path.isfile(cert)):
            raise IOError, "certificate '%s' and/or key '%s' not found"% (
                                                                cert, key)
        try:
            self.server = VerifyingServerSSL((loc, port), key, cert)
        except socket.error:
            LOGGER.error('Unable to start the server.' +
                (' Port %d is in use' % port ) +
                ' (Perhaps openmolar server is already running?)')
            return

        if loc == "":
            readable_loc = "on all interfaces"
        else:
            readable_loc = loc
        LOGGER.info(
            "listening for ssl connections %s port %d"% (readable_loc, port))
        LOGGER.debug("using cert %s"% cert)
        LOGGER.debug("using key %s"% key)

        # daemonise the process and write to /var/run
        self.start_(stderr=logger.LOCATION)

        self.server.register_instance(PermissionDispatcher())
        for manager, hash in config.managers:
            self.server.add_user(manager, hash)

        server_thread = threading.Thread(target=self.server.serve_forever)
        server_thread.start()

    def stop(self):
        '''
        stop the server
        '''
        if not self.is_running:
            return
        LOGGER.info("Stopping server")
        try:
            self.server.shutdown()
        except AttributeError:
            # will be thrown if self.server is None
            # or pre 2.6 Baseserver(which lacks this function)
            pass
        self.stop_()

    def restart(self):
        '''
        restart the server
        '''
        self.stop()
        time.sleep(1)
        self.start()

    def status(self):
        '''
        report the status of the server
        '''
        self.status_()
Example #4
0
class OMServer(Service):

    server = None
    '''
    A pointer to the :doc:`VerifyingServerSSL`
    '''
    def __init__(self, verbose=False):
        if verbose:
            LOGGER.setLevel(logging.DEBUG)
            LOGGER.debug("logging in verbose mode")
            import lib_openmolar
            LOGGER.debug("using module lib_openmolar from %s" %
                         lib_openmolar.__file__)
        else:
            LOGGER.setLevel(logging.INFO)

    def start(self):
        '''
        start the server
        '''
        LOGGER.info("starting OMServer Process")
        config = OMServerConfig()
        loc = config.location
        port = config.port
        key = config.private_key
        cert = config.pub_key
        if not (os.path.isfile(key) and os.path.isfile(cert)):
            raise IOError, "certificate '%s' and/or key '%s' not found" % (
                cert, key)
        try:
            self.server = VerifyingServerSSL((loc, port), key, cert)
        except socket.error:
            LOGGER.error('Unable to start the server.' +
                         (' Port %d is in use' % port) +
                         ' (Perhaps openmolar server is already running?)')
            return

        if loc == "":
            readable_loc = "on all interfaces"
        else:
            readable_loc = loc
        LOGGER.info("listening for ssl connections %s port %d" %
                    (readable_loc, port))
        LOGGER.debug("using cert %s" % cert)
        LOGGER.debug("using key %s" % key)

        # daemonise the process and write to /var/run
        self.start_(stderr=logger.LOCATION)

        self.server.register_instance(PermissionDispatcher())
        for manager, hash in config.managers:
            self.server.add_user(manager, hash)

        server_thread = threading.Thread(target=self.server.serve_forever)
        server_thread.start()

    def stop(self):
        '''
        stop the server
        '''
        if not self.is_running:
            return
        LOGGER.info("Stopping server")
        try:
            self.server.shutdown()
        except AttributeError:
            # will be thrown if self.server is None
            # or pre 2.6 Baseserver(which lacks this function)
            pass
        self.stop_()

    def restart(self):
        '''
        restart the server
        '''
        self.stop()
        time.sleep(1)
        self.start()

    def status(self):
        '''
        report the status of the server
        '''
        self.status_()