Skip to content

Commit

Permalink
Merge branch 'main' into feat/golive-form-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
amazingphilippe authored Nov 22, 2024
2 parents da088c2 + 5285120 commit e40f905
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 23 deletions.
1 change: 1 addition & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ RUN apt-get update \
emacs \
exa \
fd-find \
fzf \
git \
iputils-ping \
iproute2 \
Expand Down
4 changes: 4 additions & 0 deletions .devcontainer/scripts/installations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ echo -e "alias ll='exa -alh@ --git'" >> ~/.zshrc
echo -e "alias lt='exa -al -T -L 2'" >> ~/.zshrc
echo -e "alias poe='poetry run poe'" >> ~/.zshrc

echo -e "# fzf key bindings and completion" >> ~/.zshrc
echo -e "source /usr/share/doc/fzf/examples/key-bindings.zsh" >> ~/.zshrc
echo -e "source /usr/share/doc/fzf/examples/completion.zsh" >> ~/.zshrc

# Poetry autocomplete
echo -e "fpath+=/.zfunc" >> ~/.zshrc
echo -e "autoload -Uz compinit && compinit"
Expand Down
32 changes: 30 additions & 2 deletions gunicorn_config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import os
import sys
import time
import traceback

import gunicorn # type: ignore
import newrelic.agent # See https://bit.ly/2xBVKBH

newrelic.agent.initialize() # noqa: E402
environment = os.environ.get("NOTIFY_ENVIRONMENT")
newrelic.agent.initialize(environment=environment) # noqa: E402

# Guincorn sets the server type on our app. We don't want to show it in the header in the response.
gunicorn.SERVER = "Undisclosed"
Expand All @@ -20,10 +22,34 @@
# to be larger than the idle timeout configured for the load balancer.
# > By default, Elastic Load Balancing sets the idle timeout value for your load balancer to 60 seconds.
# https://docs.aws.amazon.com/elasticloadbalancing/latest/application/application-load-balancers.html#connection-idle-timeout
on_aws = os.environ.get("NOTIFY_ENVIRONMENT", "") in ["production", "staging", "scratch", "dev"]
on_aws = environment in ["production", "staging", "scratch", "dev"]
if on_aws:
keepalive = 75

# The default graceful timeout period for Kubernetes is 30 seconds, so
# make sure that the timeouts defined here are less than the configured
# Kubernetes timeout. This ensures that the gunicorn worker will exit
# before the Kubernetes pod is terminated. This is important because
# Kubernetes will send a SIGKILL to the pod if it does not terminate
# within the grace period. If the worker is still processing requests
# when it receives the SIGKILL, it will be terminated abruptly and
# will not be able to finish processing the request. This can lead to
# 502 errors being returned to the client.
#
# Also, some libraries such as NewRelic might need some time to finish
# initialization before the worker can start processing requests. The
# timeout values should consider these factors.
#
# Gunicorn config:
# https://docs.gunicorn.org/en/stable/settings.html#graceful-timeout
#
# Kubernetes config:
# https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/
graceful_timeout = 85
timeout = 90

# Start timer for total running time
start_time = time.time()

def on_starting(server):
server.log.info("Starting Notifications Admin")
Expand All @@ -36,7 +62,9 @@ def worker_abort(worker):


def on_exit(server):
elapsed_time = time.time() - start_time
server.log.info("Stopping Notifications Admin")
server.log.info("Total gunicorn Admin running time: {:.2f} seconds".format(elapsed_time))


def worker_int(worker):
Expand Down
12 changes: 11 additions & 1 deletion newrelic.ini
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,16 @@ browser_monitoring.auto_instrument = false
# call tree.
# thread_profiler.enabled = true

# If this setting is enabled, it will capture package and version
# information on startup of the agent that is displayed in the APM
# environment tab.
# In applications that have a large number of packages, having this
# setting enabled may cause a CPU spike as it captures all the package
# and version information. It is recommended in those cases to disable
# this setting.
# Disabling this setting will disable the ability to detect vulnerabilities in outdated packages.
package_reporting.enabled = false

# ---------------------------------------------------------------------------

#
Expand All @@ -188,7 +198,7 @@ browser_monitoring.auto_instrument = false
# specific environment will be used when the environment argument to the
# newrelic.agent.initialize() function has been defined to be either
# "development", "test", "staging" or "production".
#


[newrelic:development]
# monitor_mode = false
Expand Down
52 changes: 33 additions & 19 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ redis = "3.5.3" # pinned for now
xlrd = "1.2.0" # this is pinned so that we can continue to support .xslm files; see https://github.com/pyexcel/pyexcel-xls/issues/53
# Putting upgrade on hold due to v1.0.0 using sha512 instead of sha1 by default
itsdangerous = "2.2.0" # pyup: <1.0.0
newrelic = "8.10.0" # Pinned to 8.10.0 for now, 8.11.0 caused a performance regression: https://gcdigital.slack.com/archives/C012W5K734Y/p1709668046344929
newrelic = "10.3.0"
aws-xray-sdk = "^2.14.0"

validators = "^0.28.3"
Expand Down

0 comments on commit e40f905

Please sign in to comment.