diff --git a/rhodecode/config/environment.py b/rhodecode/config/environment.py --- a/rhodecode/config/environment.py +++ b/rhodecode/config/environment.py @@ -28,7 +28,7 @@ from rhodecode.config import utils from rhodecode.lib.utils import load_rcextensions from rhodecode.lib.utils2 import str2bool -from rhodecode.lib.vcs import connect_vcs, start_vcs_server +from rhodecode.lib.vcs import connect_vcs log = logging.getLogger(__name__) @@ -69,15 +69,6 @@ def load_pyramid_environment(global_conf # initialize vcs client and optionally run the server if enabled vcs_server_uri = settings['vcs.server'] vcs_server_enabled = settings['vcs.server.enable'] - start_server = ( - settings['vcs.start_server'] and - not int(os.environ.get('RC_VCSSERVER_TEST_DISABLE', '0'))) - - if vcs_server_enabled and start_server: - log.info("Starting vcsserver") - start_vcs_server(server_and_port=vcs_server_uri, - protocol=utils.get_vcs_server_protocol(settings), - log_level=settings['vcs.server.log_level']) utils.configure_vcs(settings) diff --git a/rhodecode/lib/vcs/__init__.py b/rhodecode/lib/vcs/__init__.py --- a/rhodecode/lib/vcs/__init__.py +++ b/rhodecode/lib/vcs/__init__.py @@ -111,63 +111,6 @@ def connect_vcs(server_and_port, protoco raise Exception('Invalid vcs server protocol "{}"'.format(protocol)) -# TODO: johbo: This function should be moved into our test suite, there is -# no reason to support starting the vcsserver in Enterprise itself. -def start_vcs_server(server_and_port, protocol, log_level=None): - """ - Starts the vcs server in a subprocess. - """ - log.info('Starting VCSServer as a sub process with %s protocol', protocol) - if protocol == 'http': - return _start_http_vcs_server(server_and_port, log_level) - else: - raise Exception('Invalid vcs server protocol "{}"'.format(protocol)) - - -def _start_http_vcs_server(server_and_port, log_level=None): - # TODO: mikhail: shutdown if an http server already runs - - host, port = server_and_port.rsplit(":", 1) - args = [ - 'pserve', 'rhodecode/tests/vcsserver_http.ini', - 'http_port=%s' % (port, ), 'http_host=%s' % (host, )] - proc = subprocess32.Popen(args) - - def cleanup_server_process(): - proc.kill() - atexit.register(cleanup_server_process) - - server = create_vcsserver_proxy(server_and_port, protocol='http') - _wait_until_vcs_server_is_reachable(server) - - -def _wait_until_vcs_server_is_reachable(server, timeout=40): - begin = time.time() - while (time.time() - begin) < timeout: - try: - server.ping() - return - except (VCSCommunicationError, pycurl.error): - log.debug('VCSServer not started yet, retry to connect.') - time.sleep(0.5) - raise Exception( - 'Starting the VCSServer failed or took more than {} ' - 'seconds.'.format(timeout)) - - -def _try_to_shutdown_running_server(server_and_port, protocol): - server = create_vcsserver_proxy(server_and_port, protocol) - try: - server.shutdown() - except pycurl.error: - return - - # TODO: Not sure why this is important, but without it the following start - # of the server fails. - server = create_vcsserver_proxy(server_and_port, protocol) - server.ping() - - def create_vcsserver_proxy(server_and_port, protocol): if protocol == 'http': return _create_vcsserver_proxy_http(server_and_port)