def startSocketServer(root_node, shutdownOnLastDisconnect, interactive, socket=None, extra_loggers=None):
    """
    Bind the first available unix socket.
    Return the socket file.
    """
    # Create protocol factory.
    factory = Factory()
    factory.connectionPool = set() # List of currently, active connections
    factory.protocol = CliClientProtocol
    factory.shutdownOnLastDisconnect = shutdownOnLastDisconnect
    factory.root_node = root_node
    factory.interactive = interactive
    factory.extra_loggers = extra_loggers or []
    factory.runtime_options = Options()

    # Listen on socket.
    if socket:
        reactor.listenUNIX(socket, factory)
    else:
        # Find a socket to listen on. (if no socket was given.)
        i = 0
        while True:
            try:
                socket = '/tmp/deployer.sock.%s.%i' % (getpass.getuser(), i)
                reactor.listenUNIX(socket, factory)
                break
            except CannotListenError:
                i += 1

                # When 100 times failed, cancel server
                if i == 100:
                    logging.warning('100 times failed to listen on posix socket. Please clean up old sockets.')
                    raise

    return socket


# =================[ Startup]=================
dataset/ETHPy150Open jonathanslenders/python-deployer/deployer/run/socket_server.py/startSocketServer/original