Skip to content

Commit

Permalink
Revert "Moving cwagent check outside of run celery (#2027)" (#2028)
Browse files Browse the repository at this point in the history
This reverts commit a7b6726.
  • Loading branch information
ben851 authored Nov 20, 2023
1 parent a7b6726 commit 1a8e712
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 21 deletions.
21 changes: 0 additions & 21 deletions scripts/cwcheck.sh

This file was deleted.

21 changes: 21 additions & 0 deletions scripts/run_celery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@ set -e

# Runs celery with all celery queues except the throtted sms queue.

# Check and see if this is running in K8s and if so, wait for cloudwatch agent
if [ -n "${STATSD_HOST}" ]; then
echo "Initializing... Waiting for CWAgent to become ready within the next 30 seconds."
timeout=30
while [ $timeout -gt 0 ]; do
if nc -vz "$STATSD_HOST" 25888; then
echo "CWAgent is Ready."
break
else
echo "Waiting for CWAgent to become ready."
sleep 1
timeout=$((timeout - 1))
fi
done

if [ $timeout -eq 0 ]; then
echo "Timeout reached. CWAgent did not become ready in 30 seconds."
exit 1
fi
fi

echo "Start celery, concurrency: ${CELERY_CONCURRENCY-4}"

celery -A run_celery.notify_celery worker --pidfile="/tmp/celery.pid" --loglevel=INFO --concurrency="${CELERY_CONCURRENCY-4}" -Q database-tasks,-priority-database-tasks.fifo,-normal-database-tasks,-bulk-database-tasks,job-tasks,notify-internal-tasks,periodic-tasks,priority-tasks,normal-tasks,bulk-tasks,reporting-tasks,research-mode-tasks,retry-tasks,send-sms-tasks,send-sms-high,send-sms-medium,send-sms-low,send-email-tasks,service-callbacks,delivery-receipts
21 changes: 21 additions & 0 deletions scripts/run_celery_beat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,25 @@ set -e

# Runs the celery beat process, i.e the Celery periodic tasks.

# Check and see if this is running in K8s and if so, wait for cloudwatch agent
if [ -n "${STATSD_HOST}" ]; then
echo "Initializing... Waiting for CWAgent to become ready within the next 30 seconds."
timeout=30
while [ $timeout -gt 0 ]; do
if nc -vz "$STATSD_HOST" 25888; then
echo "CWAgent is Ready."
break
else
echo "Waiting for CWAgent to become ready."
sleep 1
timeout=$((timeout - 1))
fi
done

if [ $timeout -eq 0 ]; then
echo "Timeout reached. CWAgent did not become ready in 30 seconds."
exit 1
fi
fi

celery -A run_celery.notify_celery beat --loglevel=INFO
21 changes: 21 additions & 0 deletions scripts/run_celery_core_tasks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@ set -e
# Runs celery with all celery queues except send-throttled-sms-tasks,
# send-sms-* and send-email-*.

# Check and see if this is running in K8s and if so, wait for cloudwatch agent
if [ -n "${STATSD_HOST}" ]; then
echo "Initializing... Waiting for CWAgent to become ready within the next 30 seconds."
timeout=30
while [ $timeout -gt 0 ]; do
if nc -vz "$STATSD_HOST" 25888; then
echo "CWAgent is Ready."
break
else
echo "Waiting for CWAgent to become ready."
sleep 1
timeout=$((timeout - 1))
fi
done

if [ $timeout -eq 0 ]; then
echo "Timeout reached. CWAgent did not become ready in 30 seconds."
exit 1
fi
fi

echo "Start celery, concurrency: ${CELERY_CONCURRENCY-4}"

celery -A run_celery.notify_celery worker --pidfile="/tmp/celery.pid" --loglevel=INFO --concurrency="${CELERY_CONCURRENCY-4}" -Q database-tasks,-priority-database-tasks.fifo,-normal-database-tasks,-bulk-database-tasks,job-tasks,notify-internal-tasks,periodic-tasks,priority-tasks,normal-tasks,bulk-tasks,reporting-tasks,research-mode-tasks,retry-tasks,service-callbacks,delivery-receipts
21 changes: 21 additions & 0 deletions scripts/run_celery_send_email.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@ set -e

# Runs celery with only the send-email-* queues.

# Check and see if this is running in K8s and if so, wait for cloudwatch agent
if [ -n "${STATSD_HOST}" ]; then
echo "Initializing... Waiting for CWAgent to become ready within the next 30 seconds."
timeout=30
while [ $timeout -gt 0 ]; do
if nc -vz "$STATSD_HOST" 25888; then
echo "CWAgent is Ready."
break
else
echo "Waiting for CWAgent to become ready."
sleep 1
timeout=$((timeout - 1))
fi
done

if [ $timeout -eq 0 ]; then
echo "Timeout reached. CWAgent did not become ready in 30 seconds."
exit 1
fi
fi

echo "Start celery, concurrency: ${CELERY_CONCURRENCY-4}"

# TODO: we shouldn't be using the send-email-tasks queue anymore, once we verify this we can remove it
Expand Down
21 changes: 21 additions & 0 deletions scripts/run_celery_send_sms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@ set -e

# Runs celery with only the send-sms-* queues.

# Check and see if this is running in K8s and if so, wait for cloudwatch agent
if [ -n "${STATSD_HOST}" ]; then
echo "Initializing... Waiting for CWAgent to become ready within the next 30 seconds."
timeout=30
while [ $timeout -gt 0 ]; do
if nc -vz "$STATSD_HOST" 25888; then
echo "CWAgent is Ready."
break
else
echo "Waiting for CWAgent to become ready."
sleep 1
timeout=$((timeout - 1))
fi
done

if [ $timeout -eq 0 ]; then
echo "Timeout reached. CWAgent did not become ready in 30 seconds."
exit 1
fi
fi

echo "Start celery, concurrency: ${CELERY_CONCURRENCY-4}"

# TODO: we shouldn't be using the send-sms-tasks queue anymore - once we verify this we can remove it
Expand Down
21 changes: 21 additions & 0 deletions scripts/run_celery_sms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,25 @@ set -e

# Runs celery with only the throttled sms sending queue.

# Check and see if this is running in K8s and if so, wait for cloudwatch agent
if [ -n "${STATSD_HOST}" ]; then
echo "Initializing... Waiting for CWAgent to become ready within the next 30 seconds."
timeout=30
while [ $timeout -gt 0 ]; do
if nc -vz "$STATSD_HOST" 25888; then
echo "CWAgent is Ready."
break
else
echo "Waiting for CWAgent to become ready."
sleep 1
timeout=$((timeout - 1))
fi
done

if [ $timeout -eq 0 ]; then
echo "Timeout reached. CWAgent did not become ready in 30 seconds."
exit 1
fi
fi

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

0 comments on commit 1a8e712

Please sign in to comment.