##// END OF EJS Templates
env: removed old not used code for starting vcsserver together with rhodecode.
marcink -
r2458:457e5c61 default
parent child Browse files
Show More
@@ -28,7 +28,7 b' from rhodecode.config import utils'
28
28
29 from rhodecode.lib.utils import load_rcextensions
29 from rhodecode.lib.utils import load_rcextensions
30 from rhodecode.lib.utils2 import str2bool
30 from rhodecode.lib.utils2 import str2bool
31 from rhodecode.lib.vcs import connect_vcs, start_vcs_server
31 from rhodecode.lib.vcs import connect_vcs
32
32
33 log = logging.getLogger(__name__)
33 log = logging.getLogger(__name__)
34
34
@@ -69,15 +69,6 b' def load_pyramid_environment(global_conf'
69 # initialize vcs client and optionally run the server if enabled
69 # initialize vcs client and optionally run the server if enabled
70 vcs_server_uri = settings['vcs.server']
70 vcs_server_uri = settings['vcs.server']
71 vcs_server_enabled = settings['vcs.server.enable']
71 vcs_server_enabled = settings['vcs.server.enable']
72 start_server = (
73 settings['vcs.start_server'] and
74 not int(os.environ.get('RC_VCSSERVER_TEST_DISABLE', '0')))
75
76 if vcs_server_enabled and start_server:
77 log.info("Starting vcsserver")
78 start_vcs_server(server_and_port=vcs_server_uri,
79 protocol=utils.get_vcs_server_protocol(settings),
80 log_level=settings['vcs.server.log_level'])
81
72
82 utils.configure_vcs(settings)
73 utils.configure_vcs(settings)
83
74
@@ -111,63 +111,6 b' def connect_vcs(server_and_port, protoco'
111 raise Exception('Invalid vcs server protocol "{}"'.format(protocol))
111 raise Exception('Invalid vcs server protocol "{}"'.format(protocol))
112
112
113
113
114 # TODO: johbo: This function should be moved into our test suite, there is
115 # no reason to support starting the vcsserver in Enterprise itself.
116 def start_vcs_server(server_and_port, protocol, log_level=None):
117 """
118 Starts the vcs server in a subprocess.
119 """
120 log.info('Starting VCSServer as a sub process with %s protocol', protocol)
121 if protocol == 'http':
122 return _start_http_vcs_server(server_and_port, log_level)
123 else:
124 raise Exception('Invalid vcs server protocol "{}"'.format(protocol))
125
126
127 def _start_http_vcs_server(server_and_port, log_level=None):
128 # TODO: mikhail: shutdown if an http server already runs
129
130 host, port = server_and_port.rsplit(":", 1)
131 args = [
132 'pserve', 'rhodecode/tests/vcsserver_http.ini',
133 'http_port=%s' % (port, ), 'http_host=%s' % (host, )]
134 proc = subprocess32.Popen(args)
135
136 def cleanup_server_process():
137 proc.kill()
138 atexit.register(cleanup_server_process)
139
140 server = create_vcsserver_proxy(server_and_port, protocol='http')
141 _wait_until_vcs_server_is_reachable(server)
142
143
144 def _wait_until_vcs_server_is_reachable(server, timeout=40):
145 begin = time.time()
146 while (time.time() - begin) < timeout:
147 try:
148 server.ping()
149 return
150 except (VCSCommunicationError, pycurl.error):
151 log.debug('VCSServer not started yet, retry to connect.')
152 time.sleep(0.5)
153 raise Exception(
154 'Starting the VCSServer failed or took more than {} '
155 'seconds.'.format(timeout))
156
157
158 def _try_to_shutdown_running_server(server_and_port, protocol):
159 server = create_vcsserver_proxy(server_and_port, protocol)
160 try:
161 server.shutdown()
162 except pycurl.error:
163 return
164
165 # TODO: Not sure why this is important, but without it the following start
166 # of the server fails.
167 server = create_vcsserver_proxy(server_and_port, protocol)
168 server.ping()
169
170
171 def create_vcsserver_proxy(server_and_port, protocol):
114 def create_vcsserver_proxy(server_and_port, protocol):
172 if protocol == 'http':
115 if protocol == 'http':
173 return _create_vcsserver_proxy_http(server_and_port)
116 return _create_vcsserver_proxy_http(server_and_port)
General Comments 0
You need to be logged in to leave comments. Login now