Skip to content

Commit

Permalink
Datalake: Serve API from uwsgi and monitor with Datadog.
Browse files Browse the repository at this point in the history
  • Loading branch information
ABPLMC committed Nov 4, 2024
1 parent f61854d commit 5ae6448
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
20 changes: 19 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ MAINTAINER brian <brian@planet.com>
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8

# Required for uwsgi
# Install build tools and dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
gcc \
python3-dev \
libpcre3-dev \
libssl-dev \
git \
&& rm -rf /var/lib/apt/lists/*

# TODO: keep requirements in one place
RUN pip install \
blinker>=1.4 \
Expand All @@ -29,7 +40,14 @@ RUN pip install \
pyinotify>=0.9.4, \
raven>=5.0.0 \
'tox>4,<5' \
'datalake<2'
'datalake<2' \
uwsgi

# uwsgi statsd
RUN uwsgi --build-plugin https://github.com/Datadog/uwsgi-dogstatsd && \
mkdir -p /var/log/uwsgi



RUN mkdir -p /opt/
COPY . /opt/
Expand Down
17 changes: 17 additions & 0 deletions datalake.uwsgi.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[uwsgi]
master = true
processes = 4
enable-threads = true
single-interpreter = true

module = datalake_api.app:app
http-socket = 0.0.0.0:8000
socket = 0.0.0.0:8001

# Datadog statsd
enable-metrics = true
plugin = dogstatsd
stats-push = dogstatsd:127.0.0.1:8125,uwsgi
logto = /var/log/uwsgi/uwsgi.log


3 changes: 2 additions & 1 deletion docker_entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ case "$1" in
;;
"api")
shift
FLASK_APP=/opt/api/datalake_api/app.py flask run "$@"
echo "Starting uWSGI server"
uwsgi --ini /opt/datalake.uwsgi.ini
;;
"ingester")
shift
Expand Down

0 comments on commit 5ae6448

Please sign in to comment.