Skip to content

Commit 01ead51

Browse files
committed
build: commons celery configuration
1 parent e4beadc commit 01ead51

File tree

3 files changed

+68
-3
lines changed

3 files changed

+68
-3
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Run Celery on kubernetes
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: editgroups-commons.celery.sh
6+
namespace: tool-editgroups-commons
7+
labels:
8+
name: editgroups-commons.celery.sh
9+
toolforge: tool
10+
spec:
11+
replicas: 1
12+
selector:
13+
matchLabels:
14+
name: editgroups-commons.celery.sh
15+
toolforge: tool
16+
template:
17+
metadata:
18+
labels:
19+
name: editgroups-commons.celery.sh
20+
toolforge: tool
21+
spec:
22+
containers:
23+
- name: celery
24+
image: docker-registry.tools.wmflabs.org/toolforge-python311-sssd-base:latest
25+
command: [ "/data/project/editgroups-commons/www/python/src/tasks-commons.sh" ]
26+
workingDir: /data/project/editgroups-commons/www/python/src
27+
env:
28+
- name: HOME
29+
value: /data/project/editgroups-commons
30+
imagePullPolicy: Always
31+
resources:
32+
requests:
33+
memory: "512Mi"
34+
limits:
35+
memory: "1024Mi"

restart_celery.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
#!/bin/bash
22
export GOMAXPROCS=1
3-
kubectl delete deployment editgroups.celery.sh ;
3+
TOOLNAME=$(whoami | cut -d "." -f 2)
4+
echo "Running as ${TOOLNAME}"
5+
6+
if [[ "$TOOLNAME" == "editgroups" ]]; then
7+
CELERY_FN=celery
8+
else
9+
CELERY_FN="celery-${TOOLNAME}"
10+
fi
11+
12+
kubectl delete deployment "${TOOLNAME}.celery.sh";
413
echo "Waiting for Celery to stop";
5-
sleep 45 ;
6-
kubectl create -f /data/project/editgroups/www/python/src/deployment/celery.yaml && kubectl get pods
14+
sleep 45;
15+
kubectl create -f "/data/project/${TOOLNAME}/www/python/src/deployment/${CELERY_FN}.yaml"

tasks-commons.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
4+
VENV_DIR=/data/project/editgroups-commons/www/python/venv
5+
6+
if [[ -f ${VENV_DIR}/bin/activate ]]; then
7+
source ${VENV_DIR}/bin/activate
8+
else
9+
echo "Creating virtualenv"
10+
rm -rf ${VENV_DIR}
11+
pyvenv ${VENV_DIR}
12+
source ${VENV_DIR}/bin/activate
13+
echo "Installing requirements"
14+
pip install -r requirements.txt
15+
fi;
16+
echo "Starting celery"
17+
export C_FORCE_ROOT=True
18+
/data/project/editgroups-commons/www/python/venv/bin/python3 /data/project/editgroups-commons/www/python/venv/bin/celery --app=editgroups-commons.celery:app worker -l INFO -B --concurrency=3 --max-memory-per-child=50000
19+
echo $?
20+
echo "Celery done"
21+

0 commit comments

Comments
 (0)