diff --git a/deployment/supervisor.conf b/deployment/supervisor.conf index ade6f0ecf2..0885a6426f 100644 --- a/deployment/supervisor.conf +++ b/deployment/supervisor.conf @@ -29,7 +29,7 @@ directory=/home/frappe/frappe-bench [program:frappe-bench-frappe-short-worker] -command=/home/frappe/.pyenv/versions/3.10.0/bin/bench worker-pool --num-workers 16 --queue short,default +command=bash -c "/home/frappe/frappe-bench/apps/press/deployment/wait-for-redis.sh && /home/frappe/.pyenv/versions/3.10.0/bin/bench worker-pool --num-workers 16 --queue short,default" priority=4 autostart=true autorestart=true @@ -43,7 +43,7 @@ process_name=%(program_name)s [program:frappe-bench-frappe-long-worker] -command=/home/frappe/.pyenv/versions/3.10.0/bin/bench worker-pool --num-workers 16 --queue default,short,long +command=bash -c "/home/frappe/frappe-bench/apps/press/deployment/wait-for-redis.sh && /home/frappe/.pyenv/versions/3.10.0/bin/bench worker-pool --num-workers 16 --queue default,short,long" priority=4 autostart=true autorestart=true @@ -57,7 +57,7 @@ process_name=%(program_name)s [program:frappe-bench-frappe-sync-worker] -command=/home/frappe/.pyenv/versions/3.10.0/bin/bench worker-pool --num-workers 6 --queue sync,long,default,short +command=bash -c "/home/frappe/frappe-bench/apps/press/deployment/wait-for-redis.sh && /home/frappe/.pyenv/versions/3.10.0/bin/bench worker-pool --num-workers 6 --queue sync,long,default,short" priority=4 autostart=true autorestart=true @@ -74,7 +74,7 @@ process_name=%(program_name)s # Build worker, used to run press side of builds # i.e tarring and uploading the build context. [program:frappe-bench-frappe-build-worker] -command=/home/frappe/.pyenv/versions/3.10.0/bin/bench worker-pool --num-workers 8 --queue build +command=bash -c "/home/frappe/frappe-bench/apps/press/deployment/wait-for-redis.sh && /home/frappe/.pyenv/versions/3.10.0/bin/bench worker-pool --num-workers 8 --queue build" priority=4 autostart=true autorestart=true diff --git a/deployment/wait-for-redis.sh b/deployment/wait-for-redis.sh new file mode 100644 index 0000000000..2831f24b3e --- /dev/null +++ b/deployment/wait-for-redis.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +CACHE_URL="redis://127.0.0.1:13000" +QUEUE_URL="redis://127.0.0.1:11000" + +MAX_ATTEMPTS=120 +attempts=0 + +until [ $attempts -ge $MAX_ATTEMPTS ] +do + if ( redis-cli -u $QUEUE_URL PING | grep -q PONG ) && ( redis-cli -u $CACHE_URL PING | grep -q PONG ); then + break + fi + sleep 1 + echo "Waiting for Redis to be ready..." + ((attempts=attempts+1)) +done \ No newline at end of file