fix: 🐛 add the queue + env variable
This commit is contained in:
parent
5f4a4b4ecb
commit
f5b0f9fd66
2 changed files with 54 additions and 0 deletions
30
k8s-queues.sh
Normal file
30
k8s-queues.sh
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# From https://stackoverflow.com/a/76488746/17320077
|
||||||
|
|
||||||
|
work=true
|
||||||
|
|
||||||
|
function stopQueues() {
|
||||||
|
echo "Stopping queues..."
|
||||||
|
work=false
|
||||||
|
php artisan queue:restart
|
||||||
|
sleep 45s
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# handle graceful shutdown
|
||||||
|
trap "" SIGPIPE
|
||||||
|
trap stopQueues EXIT
|
||||||
|
|
||||||
|
echo "Starting PHP queue workers..."
|
||||||
|
|
||||||
|
while $work; do
|
||||||
|
php artisan queue:work database --queue=default,database --sleep=3 --tries=3 --max-time=3600 --no-interaction
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
# Si besoin de plusieurs threads puis terminer par un done sans &
|
||||||
|
#(while $work; do
|
||||||
|
# php artisan queue:work --queue="$(grep -oP 'SQS_QUEUE=\K.*' .env)" --no-interaction
|
||||||
|
# sleep 1
|
||||||
|
#done &)
|
||||||
|
|
@ -12,6 +12,7 @@ data:
|
||||||
LOG_CHANNEL: "k8s"
|
LOG_CHANNEL: "k8s"
|
||||||
DB_HOST: "${APP_DB_HOST}"
|
DB_HOST: "${APP_DB_HOST}"
|
||||||
DB_DATABASE: "${APP_DB_DATABASE}"
|
DB_DATABASE: "${APP_DB_DATABASE}"
|
||||||
|
QUEUE_CONNECTION: "${APP_QUEUE_CONNECTION}"
|
||||||
DB_USERNAME: "${APP_DB_USERNAME}"
|
DB_USERNAME: "${APP_DB_USERNAME}"
|
||||||
DB_PASSWORD: "${APP_DB_PASSWORD}"
|
DB_PASSWORD: "${APP_DB_PASSWORD}"
|
||||||
MAIL_HOST: "${APP_MAIL_HOST}"
|
MAIL_HOST: "${APP_MAIL_HOST}"
|
||||||
|
|
@ -82,6 +83,29 @@ spec:
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: storage
|
- name: storage
|
||||||
mountPath: /app/srcs/storage
|
mountPath: /app/srcs/storage
|
||||||
|
- name: ${CI_PROJECT_PATH_SLUG}-queue-worker
|
||||||
|
image: $IMAGE_TAG
|
||||||
|
lifecycle:
|
||||||
|
preStop:
|
||||||
|
exec:
|
||||||
|
command: [ "/bin/sh", "-c", "kill -s TERM 1; while test $(ps ax | grep -v grep | grep bash | wc -l) -gt 0; do sleep 2s; done" ]
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpu: "${APP_CI_CPU_LIMIT}"
|
||||||
|
memory: "${APP_CI_MEMORY_LIMIT}"
|
||||||
|
requests:
|
||||||
|
cpu: "${APP_CI_CPU_REQUEST}"
|
||||||
|
memory: "${APP_CI_MEMORY_REQUEST}"
|
||||||
|
command:
|
||||||
|
- "bash"
|
||||||
|
args:
|
||||||
|
- "k8s-queues.sh"
|
||||||
|
envFrom:
|
||||||
|
- configMapRef:
|
||||||
|
name: ${CI_PROJECT_PATH_SLUG}-config-map
|
||||||
|
volumeMounts:
|
||||||
|
- name: storage
|
||||||
|
mountPath: /app/srcs/storage
|
||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
- name: docker-registry-credentials
|
- name: docker-registry-credentials
|
||||||
securityContext:
|
securityContext:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue