Ejemplo n.º 1
0
    def connect(self):
        """
        Connect to the command server.

        A client only needs the sequence socket(), connect(). Also note that the server does 
        not sendall()/recv() on the socket it is listening on but on the new socket returned 
        by accept().
        """
        self.notify_socket = notify.notify_server_connection(config.DEFAULT_HOST, config.DEFAULT_NOTIFY_PORT)

        self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.socket.connect((self.server, self.port))
        # send the cmdserver our configuration information
        send_msg(self.socket, self.config)
Ejemplo n.º 2
0
    def connect(self):
        """
        Connect to the command server.

        A client only needs the sequence socket(), connect(). Also note that the server does 
        not sendall()/recv() on the socket it is listening on but on the new socket returned 
        by accept().
        """
        self.notify_socket = notify.notify_server_connection(
            config.DEFAULT_HOST, config.DEFAULT_NOTIFY_PORT)

        self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.socket.connect((self.server, self.port))
        # send the cmdserver our configuration information
        send_msg(self.socket, self.config)
Ejemplo n.º 3
0
    return (cmdproc_socket, pid, config)


def fork_notify_server(notifier_path, notifier_type, notifier_port):
    try:
        pid = os.fork()
    except OSError, e:
        sys.exit(1)
    if pid == 0:
        os.execv(notifier_path, [
            notifier_path, '--type', notifier_type, '--port',
            str(notifier_port)
        ])
    while True:
        try:
            notifier_socket = notify.notify_server_connection(
                config.DEFAULT_HOST, notifier_port)
            break
        except (OSError, socket.error) as e:
            if e.errno != errno.ECONNREFUSED:
                raise
        time.sleep(config.NOTIFY_CONNECT_RETRY_TIMEOUT)

    logger.info("%s notify server \"%s\" (PID: %s) connected", notifier_type,
                notifier_path, pid)
    return (notifier_socket, pid)


def fork_context_server(context_path, cmdserver_port):
    try:
        pid = os.fork()
    except OSError, e:
Ejemplo n.º 4
0
    assert 'program' in config
    assert 'commands' in config
    logger.info("New command processor \"%s\" (PID: %s) connected with configuration:", config['program'], pid)
    logger.info(config)
    return (cmdproc_socket, pid, config)

def fork_notify_server(notifier_path, notifier_type, notifier_port):
    try:
        pid = os.fork()
    except OSError, e:
        sys.exit(1)
    if pid == 0:
        os.execv(notifier_path, [notifier_path, '--type', notifier_type, '--port', str(notifier_port)])
    while True:
        try: 
            notifier_socket = notify.notify_server_connection(config.DEFAULT_HOST, notifier_port)
            break
        except (OSError, socket.error) as e:
            if e.errno != errno.ECONNREFUSED:
                raise
        time.sleep(config.NOTIFY_CONNECT_RETRY_TIMEOUT)

            
    logger.info("%s notify server \"%s\" (PID: %s) connected", notifier_type, notifier_path, pid)
    return (notifier_socket, pid)

def fork_context_server(context_path, cmdserver_port):
    try:
        pid = os.fork()
    except OSError, e:
        sys.exit(1)