tests: fixed starting of customized gunicorn with a explicit --bind call

This commit is contained in:
RhodeCode Admin 2023-03-20 21:01:14 +01:00
parent e3aeb973eb
commit a58593dbcb
2 changed files with 19 additions and 12 deletions

View file

@ -176,8 +176,8 @@ def ini_config(request, tmpdir_factory, rcserver_port, vcsserver_port):
}},
{'handler_console': {
'class ': 'StreamHandler',
'args ': '(sys.stderr,)',
'class': 'StreamHandler',
'args': '(sys.stderr,)',
'level': log_level,
}},

View file

@ -82,13 +82,18 @@ class ServerBase(object):
def command(self):
return ' '.join(self._args)
@property
def bind_addr(self):
return '{host}:{port}'.format(**self._config)
@property
def http_url(self):
template = 'http://{host}:{port}/'
return template.format(**self._config)
def host_url(self):
return 'http://' + get_host_url(self.config_file)
host = get_host_url(self.config_file)
return f'http://{host}'
def get_rc_log(self):
with open(self.log_file) as f:
@ -137,7 +142,9 @@ class RcVCSServer(ServerBase):
def __init__(self, config_file, log_file=None):
super(RcVCSServer, self).__init__(config_file, log_file)
self._args = ['gunicorn', '--paste', self.config_file]
self._args = [
'gunicorn', '--bind', self.bind_addr,
'--paste', self.config_file]
def start(self):
env = os.environ.copy()
@ -148,10 +155,9 @@ class RcVCSServer(ServerBase):
host_url = self.host_url()
assert_no_running_instance(host_url)
log.info('rhodecode-vcsserver start command: {}'.format(' '.join(self._args)))
log.info('rhodecode-vcsserver starting at: {}'.format(host_url))
log.info('rhodecode-vcsserver command: {}'.format(self.command))
log.info('rhodecode-vcsserver logfile: {}'.format(self.log_file))
print(f'rhodecode-vcsserver starting at: {host_url}')
print(f'rhodecode-vcsserver command: {self.command}')
print(f'rhodecode-vcsserver logfile: {self.log_file}')
self.process = subprocess.Popen(
self._args, bufsize=0, env=env,
@ -169,7 +175,8 @@ class RcWebServer(ServerBase):
def __init__(self, config_file, log_file=None):
super(RcWebServer, self).__init__(config_file, log_file)
self._args = [
'gunicorn', '--worker-class', 'gevent', '--paste', config_file]
'gunicorn', '--bind', self.bind_addr, '--worker-class', 'gevent',
'--paste', self.config_file]
def start(self):
env = os.environ.copy()
@ -181,9 +188,9 @@ class RcWebServer(ServerBase):
host_url = self.host_url()
assert_no_running_instance(host_url)
log.info('rhodecode-web starting at: {}'.format(host_url))
log.info('rhodecode-web command: {}'.format(self.command))
log.info('rhodecode-web logfile: {}'.format(self.log_file))
print(f'rhodecode-web starting at: {host_url}')
print(f'rhodecode-web command: {self.command}')
print(f'rhodecode-web logfile: {self.log_file}')
self.process = subprocess.Popen(
self._args, bufsize=0, env=env,