Skip to content
This repository was archived by the owner on Sep 12, 2018. It is now read-only.

Commit 07b558e

Browse files
author
Olivier Gambier
committed
Harmonize gunicorn ways to launch and cleanup
I'm deprecating the direct gunicorn launch stance, which only increases the confusion (we already have two ways to launch, and there is zero reason now ro not use docker-registry since @wking introduced generics opts. Docker-DCO-1.1-Signed-off-by: Olivier Gambier <[email protected]> (github: dmp42)
1 parent 36187ab commit 07b558e

File tree

4 files changed

+33
-29
lines changed

4 files changed

+33
-29
lines changed

config/gunicorn_config.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

contrib/gunicorn_config.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Gunicorn config file
2+
3+
import os
4+
5+
flavor = os.environ.get('SETTINGS_FLAVOR', 'dev')
6+
7+
reload = True
8+
bind = '%s:%s' % (
9+
os.environ.get('REGISTRY_HOST', '0.0.0.0'),
10+
os.environ.get('REGISTRY_PORT', '5000')
11+
)
12+
graceful_timeout = int(os.environ.get('GUNICORN_GRACEFUL_TIMEOUT'), 3600)
13+
timeout = int(os.environ.get('GUNICORN_SILENT_TIMEOUT'), 3600)
14+
worker_class = 'gevent'
15+
max_requests = 100
16+
workers = int(os.environ.get('GUNICORN_WORKERS', 4))
17+
log_level = 'debug'
18+
debug = True
19+
accesslog = os.environ.get('GUNICORN_ACCESS_LOG_FILE', '-')
20+
errorlog = os.environ.get('GUNICORN_ERROR_LOG_FILE', '-')
21+
access_log_format = ('%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" '
22+
'"%(a)s" %(D)s %({X-Docker-Size}o)s')
23+
24+
if flavor == 'prod' or flavor == 'staging':
25+
reload = False
26+
workers = 8
27+
debug = False
28+
log_level = 'info'

docker_registry/run.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def run_gunicorn():
7373
'--error-logfile', env.source('GUNICORN_ERROR_LOG_FILE'),
7474
'--max-requests', '100',
7575
'-k', 'gevent',
76+
'--reload', False if env.source('SETTINGS_FLAVOR') == 'prod' else True,
7677
'--graceful-timeout', env.source('GUNICORN_GRACEFUL_TIMEOUT'),
7778
'-t', env.source('GUNICORN_SILENT_TIMEOUT'),
7879
'-w', env.source('GUNICORN_WORKERS'),
@@ -97,7 +98,5 @@ def run_gunicorn():
9798
else:
9899
logger.warn('You asked we drop priviledges, but we are not root!')
99100

100-
# Stringify all args
101-
for (k, v) in enumerate(args):
102-
args[k] = str(v)
103-
os.execl(*args)
101+
# Stringify all args and call
102+
os.execl(*[str(v) for v in args])

docker_registry/server/env.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
'GUNICORN_WORKERS': '4',
1414
'GUNICORN_GRACEFUL_TIMEOUT': '3600',
1515
'GUNICORN_SILENT_TIMEOUT': '3600',
16+
'GUNICORN_USER': '',
17+
'GUNICORN_GROUP': '',
1618
'GUNICORN_ACCESS_LOG_FILE': '"-"',
1719
'GUNICORN_ERROR_LOG_FILE': '"-"',
1820
'GUNICORN_OPTS': '[]',

0 commit comments

Comments
 (0)