Skip to content

Commit

Permalink
optional datadog
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaume committed Apr 5, 2024
1 parent eb75be9 commit 7113870
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 12 deletions.
13 changes: 10 additions & 3 deletions mpcontribs-api/scripts/start.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
#!/bin/bash

zzz=$(($DEPLOYMENT*60))
set -e
zzz=$(($DEPLOYMENT * 60))
echo "$SUPERVISOR_PROCESS_NAME: waiting for $zzz seconds before start..."
sleep $zzz

pmgrc=$HOME/.pmgrc.yaml
[[ ! -e $pmgrc ]] && echo "PMG_DUMMY_VAR: dummy" > $pmgrc
[[ ! -e $pmgrc ]] && echo "PMG_DUMMY_VAR: dummy" >$pmgrc

exec wait-for-it.sh $JUPYTER_GATEWAY_HOST -q -t 50 -- ddtrace-run gunicorn "mpcontribs.api:create_app()"
CMD="gunicorn \"mpcontribs.api:create_app()\""

if [[ -n "$DD_TRACE_HOST" ]]; then
wait-for-it.sh $DD_TRACE_HOST -q -s -t 10 && CMD="ddtrace-run $CMD"
fi

exec wait-for-it.sh $JUPYTER_GATEWAY_HOST -q -t 50 -- $CMD
12 changes: 10 additions & 2 deletions mpcontribs-api/scripts/start_rq.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
#!/bin/bash

zzz=$(($DEPLOYMENT*60))
set -e
zzz=$(($DEPLOYMENT * 60))
echo "$SUPERVISOR_PROCESS_NAME: waiting for $zzz seconds before start..."
sleep $zzz

exec wait-for-it.sh $JUPYTER_GATEWAY_HOST -s -t 50 -- wait-for-it.sh $MPCONTRIBS_API_HOST -s -t 15 -- ddtrace-run flask rq $1
CMD="flask rq $1"

if [[ -n "$DD_TRACE_HOST" ]]; then
wait-for-it.sh $DD_TRACE_HOST -q -s -t 10 && CMD="ddtrace-run $CMD"
fi

exec wait-for-it.sh $JUPYTER_GATEWAY_HOST -q -s -t 50 -- \
wait-for-it.sh $MPCONTRIBS_API_HOST -q -s -t 15 -- $CMD
2 changes: 1 addition & 1 deletion mpcontribs-api/supervisord/supervisord.conf.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ environment=
DD_TRACE_SAMPLE_RATE="1"

[program:main]
command=ddtrace-run ./main.py
command=./main.py
directory=/app
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
Expand Down
5 changes: 2 additions & 3 deletions mpcontribs-kernel-gateway/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM materialsproject/devops:python-3.1010.24 as base
MAINTAINER Patrick Huck (tschaume)
RUN apt-get update && apt-get install -y --no-install-recommends libopenblas-dev libpq-dev && apt-get clean

FROM base as python-deps
Expand All @@ -10,9 +9,9 @@ ARG MORE_PIP_FLAGS
ENV MORE_PIP_FLAGS=$MORE_PIP_FLAGS
COPY requirements/deployment.txt ./requirements.txt
RUN pip install $PIP_FLAGS $MORE_PIP_FLAGS -r requirements.txt && \
python -m ipykernel install --user
python -m ipykernel install --user
RUN wget -q https://github.com/raw/vishnubob/wait-for-it/master/wait-for-it.sh && \
chmod +x wait-for-it.sh && mv wait-for-it.sh /root/.local/bin/
chmod +x wait-for-it.sh && mv wait-for-it.sh /root/.local/bin/

FROM base
COPY --from=python-deps /root/.local/lib/python3.10/site-packages /root/.local/lib/python3.10/site-packages
Expand Down
10 changes: 7 additions & 3 deletions mpcontribs-kernel-gateway/start.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#!/bin/bash

set -e
pmgrc=$HOME/.pmgrc.yaml
[[ ! -e $pmgrc ]] && echo "PMG_DUMMY_VAR: dummy" > $pmgrc
[[ ! -e $pmgrc ]] && echo "PMG_DUMMY_VAR: dummy" >$pmgrc

exec wait-for-it.sh $DD_TRACE_HOST -s -q -t 60 -- ddtrace-run jupyter kernelgateway \
--KernelGatewayApp.log_format='%(asctime)s,%(msecs)03d %(levelname)s [%(name)s] [%(module)s:%(lineno)d] - %(message)s'
CMD="jupyter kernelgateway"

if [[ -n "$DD_TRACE_HOST" ]]; then
wait-for-it.sh $DD_TRACE_HOST -q -s -t 10 && CMD="ddtrace-run $CMD"
fi

exec $CMD --KernelGatewayApp.log_format='%(asctime)s,%(msecs)03d %(levelname)s [%(name)s] [%(module)s:%(lineno)d] - %(message)s'

0 comments on commit 7113870

Please sign in to comment.