Skip to content

Commit

Permalink
Reworking the celery init on k8s so I can see logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ben851 committed Oct 11, 2023
1 parent d45511d commit ea7c4c2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 49 deletions.
18 changes: 6 additions & 12 deletions scripts/run_celery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,21 @@

# runs celery with all celery queues except the throtted sms queue

init()
{
# Wait for cwagent to become available.
set -e

# Check and see if this is running in K8s and if so, wait for cloudwatch agent
if [[ -z "${STATSD_HOST}" ]]; then
echo "Initializing... Waiting for CWAgent to become ready."
while :
do
if nc -vz $STATSD_HOST 25888; then
echo "CWAgent is Ready."
echo "CWAgent is Ready." > /dev/stderr
break;
else
echo "Waiting for CWAgent to become ready."
echo "Waiting for CWAgent to become ready." > /dev/stderr
sleep 1
fi
done
}

set -e

# Check and see if this is running in K8s and if so, wait for cloudwatch agent
if [[ -z "${STATSD_HOST}" ]]; then
init
fi

echo "Start celery, concurrency: ${CELERY_CONCURRENCY-4}"
Expand Down
23 changes: 9 additions & 14 deletions scripts/run_celery_no_sms_sending.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,23 @@

# runs celery with only the throttled sms sending queue

init()
{
# Wait for cwagent to become available.
# runs celery with all celery queues except send-throttled-sms-tasks, send-sms-tasks, send-sms-high, send-sms-medium, or send-sms-low

set -e

# Check and see if this is running in K8s and if so, wait for cloudwatch agent
if [[ -z "${STATSD_HOST}" ]]; then
echo "Initializing... Waiting for CWAgent to become ready."
while :
do
if nc -vz $STATSD_HOST 25888; then
echo "CWAgent is Ready."
echo "CWAgent is Ready." > /dev/stderr
break;
else
echo "Waiting for CWAgent to become ready."
echo "Waiting for CWAgent to become ready." > /dev/stderr
sleep 1
fi
done
}

# runs celery with all celery queues except send-throttled-sms-tasks, send-sms-tasks, send-sms-high, send-sms-medium, or send-sms-low

set -e

# Check and see if this is running in K8s and if so, wait for cloudwatch agent
if [[ -z "${STATSD_HOST}" ]]; then
init
fi

echo "Start celery, concurrency: ${CELERY_CONCURRENCY-4}"
Expand Down
16 changes: 5 additions & 11 deletions scripts/run_celery_send_sms.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
#!/bin/sh

# runs celery with only the send-sms-* queues
set -e

init()
{
# Wait for cwagent to become available.
if [[ -z "${STATSD_HOST}" ]]; then
echo "Initializing... Waiting for CWAgent to become ready."
while :
do
if nc -vz $STATSD_HOST 25888; then
echo "CWAgent is Ready."
echo "CWAgent is Ready." > /dev/stderr
break;
else
echo "Waiting for CWAgent to become ready."
echo "Waiting for CWAgent to become ready." > /dev/stderr
sleep 1
fi
done
}

set -e

if [[ -z "${STATSD_HOST}" ]]; then
init
fi

echo "Start celery, concurrency: ${CELERY_CONCURRENCY-4}"
Expand Down
18 changes: 6 additions & 12 deletions scripts/run_celery_sms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,20 @@

# runs celery with only the throttled sms sending queue

init()
{
# Wait for cwagent to become available.
set -e

if [[ -z "${STATSD_HOST}" ]]; then
echo "Initializing... Waiting for CWAgent to become ready."
while :
do
if nc -vz $STATSD_HOST 25888; then
echo "CWAgent is Ready."
echo "CWAgent is Ready." > /dev/stderr
break;
else
echo "Waiting for CWAgent to become ready."
echo "Waiting for CWAgent to become ready." > /dev/stderr
sleep 1
fi
done
}

set -e

# Check and see if this is running in K8s and if so, wait for cloudwatch agent
if [[ -z "${STATSD_HOST}" ]]; then
init
fi

celery -A run_celery.notify_celery worker --loglevel=INFO --concurrency=1 -Q send-throttled-sms-tasks

0 comments on commit ea7c4c2

Please sign in to comment.