Skip to content

Commit c90448f

Browse files
author
lijianguo
committed
chore(controller):modify redis config
1 parent 25a9550 commit c90448f

5 files changed

Lines changed: 28 additions & 13 deletions

File tree

charts/controller/templates/controller-deployment.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,21 @@ spec:
136136
fieldPath: metadata.namespace
137137
- name: DRYCC_NSQD_ADDRS
138138
value: "{{range $i := until $nsqdNodeCount}}drycc-nsqd-{{$i}}.drycc-nsqd.{{$.Release.Namespace}}.svc.{{$.Values.global.cluster_domain}}:{{$.Values.nsqd.tcp_port}}{{if lt (add 1 $i) $nsqdNodeCount}},{{end}}{{end}}"
139+
{{ if eq .Values.global.redis_location "on-cluster"}}
140+
- name: DRYCC_REDIS_ADDRS
141+
value: "{{range $i := until $redisNodeCount}}drycc-redis-{{$i}}.drycc-redis.{{$.Release.Namespace}}.svc.{{$.Values.global.cluster_domain}}:{{$.Values.redis.port}}{{if lt (add 1 $i) $redisNodeCount}},{{end}}{{end}}"
142+
{{- else if eq .Values.global.redis_location "off-cluster" }}
143+
- name: DRYCC_REDIS_ADDRS
144+
valueFrom:
145+
secretKeyRef:
146+
name: redis-creds
147+
key: addrs
148+
{{- end }}
149+
- name: DRYCC_REDIS_PASSWORD
150+
valueFrom:
151+
secretKeyRef:
152+
name: redis-creds
153+
key: password
139154
{{- range $key, $value := .Values.environment }}
140155
- name: {{ $key }}
141156
value: {{ $value | quote }}

rootfs/api/settings/production.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,12 +443,14 @@
443443
}
444444
}
445445

446-
REDIS_ADDRS = os.environ.get('REDIS_ADDRS', 'redis://127.0.0.1:6379/0').split(",")
446+
DRYCC_REDIS_ADDRS = os.environ.get('DRYCC_REDIS_ADDRS', '127.0.0.1:6379').split(",")
447+
DRYCC_REDIS_PASSWORD = os.environ.get('DRYCC_REDIS_PASSWORD', '')
447448

448449
CACHES = {
449450
"default": {
450451
"BACKEND": "django_redis.cache.RedisCache",
451-
"LOCATION": REDIS_ADDRS,
452+
"LOCATION": ['redis://:{}@{}'.format(DRYCC_REDIS_PASSWORD, DRYCC_REDIS_ADDR) \
453+
for DRYCC_REDIS_ADDR in DRYCC_REDIS_ADDRS], # noqa
452454
"OPTIONS": {
453455
"CLIENT_CLASS": "django_redis.client.ShardClient",
454456
}
@@ -514,9 +516,12 @@
514516

515517
# Celery Configuration Options
516518
CELERY_TIMEZONE = "Asia/Shanghai"
519+
CELERY_ENABLE_UTC = True
517520
CELERY_TASK_TRACK_STARTED = True
518521
CELERY_TASK_TIME_LIMIT = 30 * 60
519-
CELERY_BROKER_URL = REDIS_ADDRS[0]
520-
CELERY_RESULT_BACKEND = REDIS_ADDRS[0]
522+
CELERYD_MAX_TASKS_PER_CHILD = 200
523+
CELERY_TASK_RESULT_EXPIRES = 24 * 60 * 60
524+
CELERY_BROKER_URL ='redis://:{}@{}'.format(DRYCC_REDIS_PASSWORD, DRYCC_REDIS_ADDRS[0]) # noqa
525+
CELERY_RESULT_BACKEND = 'redis://:{}@{}'.format(DRYCC_REDIS_PASSWORD, DRYCC_REDIS_ADDRS[0]) # noqa
521526
CELERY_CACHE_BACKEND = 'django-cache'
522527
CELERY_DEFAULT_QUEUE = 'priority.middle'

rootfs/bin/boot

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ python /app/manage.py migrate --noinput
3030
# spawn a gunicorn server in the background
3131
echo ""
3232
echo "Starting up Gunicorn"
33-
gunicorn -c /app/drycc/gunicorn/config.py drycc.gunicorn.wsgi &
33+
gunicorn -c /app/drycc/gunicorn/config.py api.wsgi &
3434

3535
echo ""
3636
echo "Loading database information to Kubernetes in the background"
3737
echo "Log of the run can be found in /app/data/logs/load_db_state_to_k8s.log"
3838
# python -u avoids output buffering
3939
nohup python -u /app/manage.py load_db_state_to_k8s > /app/data/logs/load_db_state_to_k8s.log &
4040
# celery
41-
nohup su-exec nobody celery -A api worker -Q priority.low --loglevel=WARNING > /app/data/logs/celery.log 2>&1 &
42-
nohup su-exec nobody celery -A api worker -Q priority.middle --loglevel=WARNING > /app/data/logs/celery.log 2>&1 &
43-
nohup su-exec nobody celery -A api worker -Q priority.high --loglevel=WARNING > /app/data/logs/celery.log 2>&1 &
41+
nohup su-exec nobody celery -A api worker -Q priority.low --autoscale=8,1 --loglevel=WARNING > /app/data/logs/celery.log 2>&1 &
42+
nohup su-exec nobody celery -A api worker -Q priority.middle --autoscale=16,1 --loglevel=WARNING > /app/data/logs/celery.log 2>&1 &
43+
nohup su-exec nobody celery -A api worker -Q priority.high --autoscale=32,1 --loglevel=WARNING > /app/data/logs/celery.log 2>&1 &
4444
# smart shutdown on SIGTERM (SIGINT is handled by gunicorn)
4545
function on_exit() {
4646
GUNICORN_PID=$(cat /tmp/gunicorn.pid)

rootfs/drycc/gunicorn/wsgi.py

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

rootfs/requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ morph==0.1.4
1515
ndg-httpsclient==0.5.1
1616
packaging==20.4
1717
pyasn1==0.4.8
18-
pynsq==0.9.0
1918
psycopg2-binary==2.8.5
2019
pyOpenSSL==19.1.0
2120
pytz==2020.1

0 commit comments

Comments
 (0)