This repository was archived by the owner on Sep 12, 2018. It is now read-only.
File tree 6 files changed +37
-15
lines changed
6 files changed +37
-15
lines changed Original file line number Diff line number Diff line change @@ -9,9 +9,10 @@ env REGISTRY_DIR=/srv/docker/registry
9
9
env USER=www-data
10
10
env GROUP=www-data
11
11
env LOG_FILE=/var/log/docker/registry.log
12
- env NUM_WORKERS =9
12
+ env GUNICORN_WORKERS =9
13
13
14
- env ADDRESS=127.0.0.1:5000
14
+ env REGISTRY_PORT=5000
15
+ env REGISTRY_HOST=127.0.0.1
15
16
16
17
17
18
pre-start script
27
28
28
29
[ -r $REGISTRY_DIR/.venv/bin/activate ] && . $REGISTRY_DIR/.venv/bin/activate
29
30
cd $REGISTRY_DIR
30
- exec gunicorn -w $NUM_WORKERS --bind=$ADDRESS --user=$USER --group=$GROUP --log-level=$LOG_LEVEL --log-file=$LOG_FILE 2>>$LOG_FILE wsgi:application
31
+ exec gunicorn -w $GUNICORN_WORKERS --bind=$REGISTRY_HOST:$REGISTRY_PORT --user=$USER --group=$GROUP --log-level=$LOG_LEVEL --log-file=$LOG_FILE 2>>$LOG_FILE docker_registry. wsgi:application
31
32
end script
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ self_dir="${self_path%%/${self_path##*/}}"
43
43
44
44
NAME=" Docker Registry"
45
45
DAEMON=" /usr/bin/gunicorn"
46
- DAEMON_OPTS=" -D --error-logfile ${ERROR_LOGFILE} --access-logfile ${ACCESS_LOGFILE} --log-file ${LOGFILE} --pid ${PIDFILE} --max-requests 500 --graceful-timeout 3600 -t 3600 -k gevent -b ${LISTEN_IP} :${LISTEN_PORT} -w ${GUNICORN_WORKERS:- 2} wsgi:application"
46
+ DAEMON_OPTS=" -D --error-logfile ${ERROR_LOGFILE} --access-logfile ${ACCESS_LOGFILE} --log-file ${LOGFILE} --pid ${PIDFILE} --max-requests 500 --graceful-timeout 3600 -t 3600 -k gevent -b ${LISTEN_IP} :${LISTEN_PORT} -w ${GUNICORN_WORKERS:- 2} docker_registry. wsgi:application"
47
47
48
48
RED=' \e[0;31m'
49
49
GREEN=' \e[0;32m'
Original file line number Diff line number Diff line change 5
5
# Required-Start: $network $remote_fs $syslog
6
6
# Required-Stop: $network $remote_fs $syslog
7
7
# Default-Start: 2 3 4 5
8
- # Default-Stop: 0 1 6
8
+ # Default-Stop: 0 1 6
9
9
# Short-Description: Start Docker-Registry
10
10
# ## END INIT INFO
11
11
@@ -33,15 +33,15 @@ self_dir="${self_path%%/${self_path##*/}}"
33
33
# set defaults if they are not set by config
34
34
[[ -z " $RUNAS " ]] && RUNAS=$( stat --format " %U" $self_path ) # defaults to user owning this init script
35
35
[[ -z " $LOGFILE " ]] && LOGFILE=/var/log/docker-registry.log # will be chowned to $RUNAS
36
- [[ -z " $PIDFILE " ]] && PIDFILE=/var/run/docker-registry/docker-registry.pid # path will created and chowned to $RUNAS
36
+ [[ -z " $PIDFILE " ]] && PIDFILE=/var/run/docker-registry/docker-registry.pid # path will created and chowned to $RUNAS
37
37
[[ -z " $LISTEN_IP " ]] && LISTEN_IP=" 0.0.0.0"
38
38
[[ -z " $LISTEN_PORT " ]] && LISTEN_PORT=5000
39
39
[[ -z " $GUNICORN_WORKERS " ]] && GUNICORN_WORKERS=2
40
40
[[ -z " $DOCKER_REGISTRY_HOME " ]] && DOCKER_REGISTRY_HOME=${self_dir%/* }
41
41
42
42
NAME=" Docker Registry"
43
43
DAEMON=" /usr/local/bin/gunicorn"
44
- DAEMON_OPTS=" -D --access-logfile ${LOGFILE} --pid ${PIDFILE} --max-requests 500 --graceful-timeout 3600 -t 3600 -k gevent -b ${LISTEN_IP} :${LISTEN_PORT} -w ${GUNICORN_WORKERS:- 2} wsgi:application"
44
+ DAEMON_OPTS=" -D --access-logfile ${LOGFILE} --pid ${PIDFILE} --max-requests 500 --graceful-timeout 3600 -t 3600 -k gevent -b ${LISTEN_IP} :${LISTEN_PORT} -w ${GUNICORN_WORKERS:- 2} docker_registry. wsgi:application"
45
45
46
46
RED=' \e[0;31m'
47
47
GREEN=' \e[0;32m'
Original file line number Diff line number Diff line change 16
16
from .tags import * # noqa
17
17
from .images import * # noqa
18
18
from .lib import config
19
+ from .server import env
19
20
from .status import * # noqa
20
21
from .search import * # noqa
21
22
@@ -47,12 +48,13 @@ def run_gunicorn():
47
48
formatter_class = RawTextHelpFormatter )
48
49
parser .parse_args ()
49
50
50
- workers = os .environ .get ('GUNICORN_WORKERS' , '4' )
51
- port = os .environ .get ('REGISTRY_PORT' , '5000' )
52
- graceful_timeout = os .environ .get ('GUNICORN_GRACEFUL_TIMEOUT' , '3600' )
53
- silent_timeout = os .environ .get ('GUNICORN_SILENT_TIMEOUT' , '3600' )
51
+ workers = env .source ('GUNICORN_WORKERS' )
52
+ host = env .source ('REGISTRY_HOST' )
53
+ port = env .source ('REGISTRY_PORT' )
54
+ graceful_timeout = env .source ('GUNICORN_GRACEFUL_TIMEOUT' )
55
+ silent_timeout = env .source ('GUNICORN_SILENT_TIMEOUT' )
54
56
55
- address = '0.0.0.0:{0}' . format ( port )
57
+ address = '%s:%s' % ( host , port )
56
58
57
59
gunicorn_path = distutils .spawn .find_executable ('gunicorn' )
58
60
if gunicorn_path is None :
Original file line number Diff line number Diff line change
1
+ # -*- coding: utf-8 -*-
2
+
3
+ import os
4
+
5
+ __all__ = ['source' ]
6
+
7
+ defined = {
8
+ 'REGISTRY_PORT' : 5000 ,
9
+ 'REGISTRY_HOST' : '0.0.0.0' ,
10
+ 'SETTINGS_FLAVOR' : 'dev' ,
11
+ 'GUNICORN_WORKERS' : 4 ,
12
+ 'GUNICORN_GRACEFUL_TIMEOUT' : 3600 ,
13
+ 'GUNICORN_SILENT_TIMEOUT' : 3600
14
+ }
15
+
16
+
17
+ def source (key , override = None ):
18
+ return os .environ .get (key , defined [key ] if key in defined else override )
Original file line number Diff line number Diff line change 2
2
# -*- coding: utf-8 -*-
3
3
4
4
import logging
5
- import os
6
5
7
6
from .run import app
7
+ from .server import env
8
8
9
9
10
10
if __name__ == '__main__' :
11
11
# Bind to PORT if defined, otherwise default to 5000.
12
- port = int (os .environ .get ('PORT_WWW' , 5000 ))
12
+ host = env .source ('REGISTRY_HOST' )
13
+ port = int (env .source ('REGISTRY_PORT' ))
13
14
app .debug = True
14
- app .run (host = '0.0.0.0' , port = port )
15
+ app .run (host = host , port = port )
15
16
# Or you can run:
16
17
# gunicorn --access-logfile - --log-level debug --debug -b 0.0.0.0:5000 \
17
18
# -w 1 wsgi:application
You can’t perform that action at this time.
0 commit comments