Skip to content

Commit 3fd00b8

Browse files
author
lijianguo
committed
chore(controller): CELERY_BROKER use rabbitmq and modify celery-deployment cronjob
1 parent 1579ee4 commit 3fd00b8

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

charts/controller/templates/controller-celery.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ spec:
2121
labels:
2222
app: drycc-controller-celery
2323
spec:
24-
serviceAccount: drycc-controller-celery
2524
containers:
2625
- name: drycc-controller-celery-high
2726
image: {{.Values.image_registry}}{{.Values.org}}/controller:{{.Values.image_tag}}
@@ -62,4 +61,4 @@ spec:
6261
{{- include "controller.envs" . | indent 10 }}
6362
{{- include "controller.volumeMounts" . | indent 10 }}
6463
imagePullPolicy: {{.Values.image_pull_policy}}
65-
{{- include "controller.volumes" . | indent 6 }}
64+
{{- include "controller.volumes" . | indent 6 }}

charts/controller/templates/controller-cronjob-daily.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ spec:
2323
- /bin/bash
2424
- -c
2525
args:
26-
- python /app/manage.py push_data_to_influxdb
26+
- python /app/manage.py load_db_state_to_k8s
2727
{{- include "controller.envs" . | indent 12 }}
2828
volumeMounts:
2929
- mountPath: /etc/slugrunner
@@ -79,4 +79,3 @@ spec:
7979
{{- include "controller.envs" . | indent 12 }}
8080
{{- include "controller.volumeMounts" . | indent 12 }}
8181
{{- include "controller.volumes" . | indent 10 }}
82-

rootfs/Dockerfile.test

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ RUN echo https://dl-cdn.alpinelinux.org/alpine/edge/testing >>/etc/apk/repositor
2929
shadow \
3030
postgresql \
3131
redis \
32+
rabbitmq-server \
3233
&& mkdir -p /run/postgresql $PGDATA \
3334
&& chown -R postgres:postgres /run/postgresql $PGDATA \
3435
&& apk del .build-deps \

rootfs/api/settings/production.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -527,8 +527,7 @@
527527
CELERY_TASK_TIME_LIMIT = 30 * 60
528528
CELERYD_MAX_TASKS_PER_CHILD = 200
529529
CELERY_TASK_RESULT_EXPIRES = 24 * 60 * 60
530-
CELERY_BROKER_URL ='redis://:{}@{}'.format(DRYCC_REDIS_PASSWORD, DRYCC_REDIS_ADDRS[0]) # noqa
531-
CELERY_RESULT_BACKEND = 'redis://:{}@{}'.format(DRYCC_REDIS_PASSWORD, DRYCC_REDIS_ADDRS[0]) # noqa
530+
CELERY_BROKER_URL = os.environ.get('DRYCC_RABBITMQ_URL', 'amqp://guest:[email protected]:5672/') # noqa
532531
CELERY_CACHE_BACKEND = 'django-cache'
533532
CELERY_DEFAULT_QUEUE = 'priority.middle'
534533

rootfs/bin/test-unit

+7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ function start_redis() {
1212
cd -
1313
}
1414

15+
function start_rabbitmq() {
16+
cd /tmp
17+
nohup rabbitmq-server > /var/log/rabbitmq.log 2>&1 &
18+
cd -
19+
}
20+
1521
function start_celery() {
1622
cd /tmp
1723
nohup su-exec nobody celery -A api worker -Q priority.low,priority.middle,priority.high --loglevel=info > /var/log/celery.log 2>&1 &
@@ -20,6 +26,7 @@ function start_celery() {
2026

2127
su-exec postgres pg_ctl -D "$PGDATA" start
2228
start_redis
29+
start_rabbitmq
2330
start_celery
2431
python3 manage.py check
2532
coverage run manage.py test --settings=api.settings.testing --noinput api scheduler.tests

0 commit comments

Comments
 (0)