Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion http_service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ ENV MPLCONFIGDIR=/opt/matplotlib
RUN python -c "import matplotlib.font_manager" && chmod -R a+rwX $MPLCONFIGDIR

# Run the Pulse listener in the background
CMD (bugbug-http-pulse-listener &) && gunicorn -b 0.0.0.0:$PORT bugbug_http.app --preload --timeout 30 -w 3
CMD (bugbug-http-pulse-listener &) && gunicorn -c python:bugbug_http.gunicorn_conf -b 0.0.0.0:$PORT bugbug_http.app --preload --timeout 30 -w 3
23 changes: 23 additions & 0 deletions http_service/bugbug_http/gunicorn_conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.

"""Gunicorn configuration for the web processes (loaded with ``-c python:bugbug_http.gunicorn_conf``)."""

import gc

# With --preload, the workers share the master's memory (the imported modules) until they write to
# it, and a garbage collection writes to every object it traverses. Following
# https://docs.python.org/3/library/gc.html#gc.freeze, collections are disabled while the app is
# preloaded (this module is loaded before it), so that they don't free objects and leave holes
# that the workers' allocations would fill, writing to the shared pages.
gc.disable()


def pre_fork(server, worker):
# Move the objects allocated so far to the permanent generation, which collections don't
# traverse, then enable the collections again: in the master, which keeps running (e.g. Sentry's
# threads), and in the worker, which inherits them.
gc.freeze()
gc.enable()
2 changes: 1 addition & 1 deletion scripts/integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ sleep 1
redis-cli -n 4 FLUSHDB

# Start the http server
gunicorn -b 127.0.0.1:8000 bugbug_http.app --preload --timeout 30 -w 3 &
gunicorn -c python:bugbug_http.gunicorn_conf -b 127.0.0.1:8000 bugbug_http.app --preload --timeout 30 -w 3 &
gunicorn_pid=$!

# Start the background worker
Expand Down