def cmd_daemon(args): """Entry point for starting a TCP git server.""" import optparse parser = optparse.OptionParser() parser.add_option("-l", "--listen_address", dest="listen_address", default="127.0.0.1", help="Binding IP address.") parser.add_option("-p", "--port", dest="port", type=int, default=TCP_GIT_PORT, help="Binding TCP port.") parser.add_option("-c", "--swift_config", dest="swift_config", default="", help="Path to the configuration file for Swift backend.") options, args = parser.parse_args(args) try: import gevent import geventhttpclient except ImportError: print("gevent and geventhttpclient libraries are mandatory " " for use the Swift backend.") sys.exit(1) import gevent.monkey gevent.monkey.patch_socket() from dulwich.contrib.swift import load_conf from dulwich import log_utils logger = log_utils.getLogger(__name__) conf = load_conf(options.swift_config) backend = SwiftSystemBackend(logger, conf) log_utils.default_logging_config() server = TCPGitServer(backend, options.listen_address, port=options.port) server.serve_forever()
def handle(self, *args, **options): log_utils.default_logging_config() address = '0.0.0.0' port = 9418 backend = DjangitFileSystemBackend(settings.DJANGIT_REPOS_DIR) server = TCPGitServer(backend, address, port) server.serve_forever()
def main(argv=sys.argv): """Entry point for starting a TCP git server.""" MysqlRepo.setup(os.environ['DB_URL']) log_utils.default_logging_config() repos = MysqlRepo.list_repos() backendDict = { '/%s' % repo: MysqlRepo.open(repo) for repo in repos } backend = DictBackend(backendDict) server = TCPGitServer(backend, '0.0.0.0') server.serve_forever()
def daemon(path=".", address=None, port=None): """Run a daemon serving Git requests over TCP/IP. :param path: Path to the directory to serve. """ # TODO(jelmer): Support git-daemon-export-ok and --export-all. backend = FileSystemBackend(path) server = TCPGitServer(backend, address, port) server.serve_forever()
def daemon(path=".", address=None, port=None): """Run a daemon serving Git requests over TCP/IP. :param path: Path to the directory to serve. :param address: Optional address to listen on (defaults to ::) :param port: Optional port to listen on (defaults to TCP_GIT_PORT) """ # TODO(jelmer): Support git-daemon-export-ok and --export-all. backend = FileSystemBackend(path) server = TCPGitServer(backend, address, port) server.serve_forever()
def daemon(path=".", address=None, port=None): """Run a daemon serving Git requests over TCP/IP. :param path: Path to the directory to serve. """ # TODO(jelmer): Support git-daemon-export-ok and --export-all. from dulwich.server import ( FileSystemBackend, TCPGitServer, ) backend = FileSystemBackend(path) server = TCPGitServer(backend, address, port) server.serve_forever()
def __init__(self, root_path=None, listen_addr=None, perm=None, *args, **kwargs): # Default values self.perm = perm or 'r' self.root_path = root_path or '/' self.listen_addr = listen_addr or 'localhost' # Backend backend = SubFileSystemBackend(self.root_path) # Handlers by permissions handlers = PERM_MAPPING.get(self.perm, READ_HANDLERS) # This is ugly and due to the fact that TCPGitServer is and old style class TCPGitServer.__init__(self, backend, self.listen_addr, handlers=handlers, *args, **kwargs)
def run(self, directory=None): from dulwich.server import TCPGitServer from bzrlib.plugins.git.server import BzrBackend from bzrlib.trace import warning import os warning("server support in bzr-git is experimental.") if directory is None: directory = os.getcwd() backend = BzrBackend(directory) server = TCPGitServer(backend, 'localhost') server.serve_forever()
class TCPGitServerThread(threading.Thread): """Thread that runs a TCP Git server.""" def __init__(self, backend, address, port=None): super(TCPGitServerThread, self).__init__() self.setName("TCP Git server on %s:%s" % (address, port)) self.server = TCPGitServer(backend, address, port) def run(self): self.server.serve_forever() def get_address(self): return self.server.server_address def stop(self): self.server.shutdown()
def _start_server(self, repo): backend = DictBackend({b"/": repo}) dul_server = TCPGitServer(backend, b"localhost", 0, handlers=self._handlers()) self._check_server(dul_server) self.addCleanup(dul_server.shutdown) self.addCleanup(dul_server.server_close) threading.Thread(target=dul_server.serve).start() self._server = dul_server _, port = self._server.socket.getsockname() return port
def __init__(self, backend, address, port=None): super(TCPGitServerThread, self).__init__() self.setName("TCP Git server on %s:%s" % (address, port)) self.server = TCPGitServer(backend, address, port)