def set_up_server(remote_base_path): # choosing free port s = socket.socket() s.bind(('',0)) ip, port = s.getsockname() s.close() del s print("Chosen URL is http://%s:%s/" % (ip, port)) # setting up the server. server = wsgiserver.CherryPyWSGIServer( (ip, port), git_http_backend.assemble_WSGI_git_app(remote_base_path) ) ip = 'localhost' # the IP the socket yields is '0.0.0.0' which is not useful for testing. return ip, port, server
def SvcDoRun(self): app = git_http_backend.assemble_WSGI_git_app( content_path=self._content_path, uri_marker=self._uri_marker # on push, nonexistent repos are autocreated by default. # uncomment 3 lines below to stop that. # ,repo_auto_create = False ) self._server_instance = wsgiserver.CherryPyWSGIServer( (self._server_ip, self._server_port), app) try: self._server_instance.start() except KeyboardInterrupt: # i know this will never happen. That's the point. # all other exceptions will bubble up, somewhere... i hope... pass finally: self._server_instance.stop()
def SvcDoRun(self): app = git_http_backend.assemble_WSGI_git_app( content_path = self._content_path, uri_marker = self._uri_marker # on push, nonexistent repos are autocreated by default. # uncomment 3 lines below to stop that. # ,repo_auto_create = False ) self._server_instance = wsgiserver.CherryPyWSGIServer( (self._server_ip, self._server_port), app ) try: self._server_instance.start() except KeyboardInterrupt: # i know this will never happen. That's the point. # all other exceptions will bubble up, somewhere... i hope... pass finally: self._server_instance.stop()
def wsgi_wrapper(environ, start_response): assert environ['PATH_INFO'].startswith(url_prefix) environ['PATH_INFO'] = '/' + os.path.basename(working_dir) + '/' + environ['PATH_INFO'][len(url_prefix):] return assemble_WSGI_git_app(content_path = os.path.dirname(working_dir))(environ, start_response)
sock.settimeout(1) try: sock.connect(('127.0.0.1', PORT)) return True except Exception, err: return False finally: sock.close() if __name__ == '__main__': if is_server_started(): print('Git server is already started') sys.exit(0) certfile = keyfile = None if len(sys.argv) > 1: certfile = sys.argv[1] if len(sys.argv) > 2: keyfile = sys.argv[2] app = assemble_WSGI_git_app(content_path=GIT_DIR, uri_marker=URI_MARKER) httpd = CherryPyWSGIServer(('0.0.0.0', PORT), app) if certfile: httpd.ssl_adapter = SSLAdapter(certfile, keyfile) signal.signal(signal.SIGINT, stop) httpd.start()