diff --git a/app/config.py b/app/config.py index 4a11187c90..bf7014caac 100644 --- a/app/config.py +++ b/app/config.py @@ -716,10 +716,15 @@ class Scratch(Production): NOTIFY_ENVIRONMENT = "scratch" +class Dev(Production): + NOTIFY_ENVIRONMENT = "dev" + + configs = { "development": Development, "test": Test, "production": Production, "staging": Staging, "scratch": Scratch, + "dev": Dev, } diff --git a/gunicorn_config.py b/gunicorn_config.py index 969e89ff16..665655e00a 100644 --- a/gunicorn_config.py +++ b/gunicorn_config.py @@ -12,7 +12,7 @@ bind = "0.0.0.0:{}".format(os.getenv("PORT")) accesslog = "-" -on_aws = os.environ.get("NOTIFY_ENVIRONMENT", "") in ["production", "staging", "scratch"] +on_aws = os.environ.get("NOTIFY_ENVIRONMENT", "") in ["production", "staging", "scratch", "dev"] if on_aws: # To avoid load balancers reporting errors on shutdown instances, see AWS doc # > We also recommend that you configure the idle timeout of your application diff --git a/migrations/versions/0439_add_index_n_history.py b/migrations/versions/0439_add_index_n_history.py new file mode 100644 index 0000000000..b59a4ed8b4 --- /dev/null +++ b/migrations/versions/0439_add_index_n_history.py @@ -0,0 +1,34 @@ +""" + +Revision ID: 0439_add_index_n_history +Revises: 0438_sms_templates_msgs_left +Create Date: 2023-10-05 00:00:00 + +""" +from datetime import datetime + +from alembic import op + +revision = "0439_add_index_n_history" +down_revision = "0438_sms_templates_msgs_left" + + +def index_exists(name): + connection = op.get_bind() + result = connection.execute( + "SELECT exists(SELECT 1 from pg_indexes where indexname = '{}') as ix_exists;".format(name) + ).first() + return result.ix_exists + + +# option 1 +def upgrade(): + op.execute("COMMIT") + if not index_exists("ix_notification_history_created_by_id"): + op.create_index( + op.f("ix_notification_history_created_by_id"), "notification_history", ["created_by_id"], postgresql_concurrently=True + ) + + +def downgrade(): + op.drop_index(op.f("ix_notification_history_created_by_id"), table_name="notification_history") diff --git a/newrelic.ini b/newrelic.ini index 531709557e..eddd873bfd 100644 --- a/newrelic.ini +++ b/newrelic.ini @@ -203,4 +203,7 @@ error_collector.ignore_errors = app.v2.errors:BadRequestError jsonschema.excepti [newrelic:scratch] # monitor_mode = false +[newrelic:dev] +# monitor_mode = false + # --------------------------------------------------------------------------- diff --git a/scripts/run_celery_exit.sh b/scripts/run_celery_exit.sh index 7e7625b25d..e34fdf7495 100755 --- a/scripts/run_celery_exit.sh +++ b/scripts/run_celery_exit.sh @@ -18,8 +18,8 @@ function send_signal_to_celery_processes { # refresh pids to account for the case that some workers may have terminated but others not get_celery_pids # send signal to all remaining apps - echo ${APP_PIDS} | tr -d '\n' | tr -s ' ' | xargs echo "Sending signal ${1} to processes with pids: " > /dev/stderr - echo "We will send ${1} signal" > /dev/stderr + echo ${APP_PIDS} | tr -d '\n' | tr -s ' ' | xargs echo "Sending signal ${1} to processes with pids: " >> /proc/1/fd/1 + echo "We will send ${1} signal" >> /proc/1/fd/1 for value in ${APP_PIDS} do echo kill -s ${1} $value @@ -30,14 +30,14 @@ function send_signal_to_celery_processes { function error_exit() { - echo "Error: $1" > /dev/stderr + echo "Error: $1" >> /proc/1/fd/1 } function ensure_celery_is_running { if [ "${APP_PIDS}" = "" ]; then - echo "There are no celery processes running, this container is bad" > /dev/stderr + echo "There are no celery processes running, this container is bad" >> /proc/1/fd/1 - echo "Exporting CF information for diagnosis" > /dev/stderr + echo "Exporting CF information for diagnosis" >> /proc/1/fd/1 env | grep CF @@ -49,24 +49,24 @@ function ensure_celery_is_running { function on_exit { apk add --no-cache procps apk add --no-cache coreutils - echo "multi worker app exiting" + echo "multi worker app exiting" >> /proc/1/fd/1 wait_time=0 send_signal_to_celery_processes TERM # check if the apps are still running every second while [[ "$wait_time" -le "$TERMINATE_TIMEOUT" ]]; do - echo "exit function is running with wait time of 9s" > /dev/stderr + echo "exit function is running with wait time of 9s" >> /proc/1/fd/1 get_celery_pids ensure_celery_is_running let wait_time=wait_time+1 sleep 1 done - echo "sending signal to celery to kill process as TERM signal has not timed out" > /dev/stderr + echo "sending signal to celery to kill process as TERM signal has not timed out" >> /proc/1/fd/1 send_signal_to_celery_processes KILL } -echo "Run script pid: $$" +echo "Run script pid: $$" >> /proc/1/fd/1 on_exit