introduce supervisord manager
Browse files- Dockerfile +6 -1
- bin/run_api_testing.sh +5 -0
- bin/run_control_plane.sh +6 -0
- bin/run_ingest.sh +5 -0
- bin/run_ml.sh +6 -0
- entrypoint.sh +1 -1
- supervisord.conf +44 -0
Dockerfile
CHANGED
|
@@ -25,16 +25,21 @@ COPY --from=cp_source /app/app /app/control-plane/app
|
|
| 25 |
|
| 26 |
COPY entrypoint.sh /app/entrypoint.sh
|
| 27 |
RUN chmod +x /app/entrypoint.sh
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
ENV PORT=7860
|
| 30 |
ENV INGEST_URL=http://localhost:8080
|
| 31 |
ENV ML_SERVICE_URL=http://localhost:8001
|
| 32 |
ENV API_TESTING_URL=http://localhost:9090
|
| 33 |
|
|
|
|
|
|
|
| 34 |
RUN useradd -m -u 1000 appuser && \
|
| 35 |
chown -R appuser:appuser /app
|
| 36 |
USER appuser
|
| 37 |
|
| 38 |
EXPOSE 7860
|
| 39 |
|
| 40 |
-
ENTRYPOINT ["/
|
|
|
|
| 25 |
|
| 26 |
COPY entrypoint.sh /app/entrypoint.sh
|
| 27 |
RUN chmod +x /app/entrypoint.sh
|
| 28 |
+
COPY supervisord.conf /etc/supervisord.conf
|
| 29 |
+
COPY bin /app/bin
|
| 30 |
+
RUN chmod +x /app/bin/*.sh || true
|
| 31 |
|
| 32 |
ENV PORT=7860
|
| 33 |
ENV INGEST_URL=http://localhost:8080
|
| 34 |
ENV ML_SERVICE_URL=http://localhost:8001
|
| 35 |
ENV API_TESTING_URL=http://localhost:9090
|
| 36 |
|
| 37 |
+
RUN apt-get update && apt-get install -y --no-install-recommends supervisor && rm -rf /var/lib/apt/lists/*
|
| 38 |
+
|
| 39 |
RUN useradd -m -u 1000 appuser && \
|
| 40 |
chown -R appuser:appuser /app
|
| 41 |
USER appuser
|
| 42 |
|
| 43 |
EXPOSE 7860
|
| 44 |
|
| 45 |
+
ENTRYPOINT ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisord.conf"]
|
bin/run_api_testing.sh
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -euo pipefail
|
| 3 |
+
|
| 4 |
+
# Run api-testing and prefix logs with [api-testing]
|
| 5 |
+
exec bash -c 'set -o pipefail; BIND_ADDR=127.0.0.1:9090 /app/api-testing/api-testing 2>&1 | sed -u "s/^/[api-testing] /"; exit ${PIPESTATUS[0]}'
|
bin/run_control_plane.sh
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -euo pipefail
|
| 3 |
+
|
| 4 |
+
# Run control-plane (uvicorn) and prefix logs with [control-plane]
|
| 5 |
+
cd /app/control-plane
|
| 6 |
+
exec bash -c 'set -o pipefail; PYTHONPATH=/app/control-plane /opt/cp_venv/bin/python -u -m uvicorn app.main:app --host 0.0.0.0 --port 7860 --workers 4 2>&1 | sed -u "s/^/[control-plane] /"; exit ${PIPESTATUS[0]}'
|
bin/run_ingest.sh
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -euo pipefail
|
| 3 |
+
|
| 4 |
+
# Run ingest-service and prefix logs with [ingest]
|
| 5 |
+
exec bash -c 'set -o pipefail; /app/ingest-service/ingest-service 2>&1 | sed -u "s/^/[ingest] /"; exit ${PIPESTATUS[0]}'
|
bin/run_ml.sh
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -euo pipefail
|
| 3 |
+
|
| 4 |
+
# Run ML service and prefix logs with [ml]
|
| 5 |
+
cd /app/ml-service
|
| 6 |
+
exec bash -c 'set -o pipefail; PYTHONPATH=/app/ml-service /opt/ml_venv/bin/python -u -m app.main 2>&1 | sed -u "s/^/[ml] /"; exit ${PIPESTATUS[0]}'
|
entrypoint.sh
CHANGED
|
@@ -26,4 +26,4 @@ unset PYTHONPATH
|
|
| 26 |
# 4. Start Control Plane (Python) on the public port 7860
|
| 27 |
cd /app/control-plane
|
| 28 |
export PYTHONPATH=/app/control-plane
|
| 29 |
-
exec /opt/cp_venv/bin/python -m uvicorn app.main:app --host 0.0.0.0 --port 7860
|
|
|
|
| 26 |
# 4. Start Control Plane (Python) on the public port 7860
|
| 27 |
cd /app/control-plane
|
| 28 |
export PYTHONPATH=/app/control-plane
|
| 29 |
+
exec /opt/cp_venv/bin/python -m uvicorn app.main:app --host 0.0.0.0 --port 7860 --workers 4
|
supervisord.conf
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[supervisord]
|
| 2 |
+
nodaemon=true
|
| 3 |
+
logfile=/dev/null
|
| 4 |
+
|
| 5 |
+
[program:ingest]
|
| 6 |
+
command=/app/bin/run_ingest.sh
|
| 7 |
+
stdout_logfile=/dev/fd/1
|
| 8 |
+
stderr_logfile=/dev/fd/2
|
| 9 |
+
autorestart=true
|
| 10 |
+
startretries=4
|
| 11 |
+
startsecs=3
|
| 12 |
+
stopsignal=TERM
|
| 13 |
+
|
| 14 |
+
[program:ml]
|
| 15 |
+
directory=/app/ml-service
|
| 16 |
+
command=/app/bin/run_ml.sh
|
| 17 |
+
environment=PYTHONPATH="/app/ml-service"
|
| 18 |
+
stdout_logfile=/dev/fd/1
|
| 19 |
+
stderr_logfile=/dev/fd/2
|
| 20 |
+
autorestart=true
|
| 21 |
+
startretries=4
|
| 22 |
+
startsecs=3
|
| 23 |
+
stopsignal=TERM
|
| 24 |
+
|
| 25 |
+
[program:api-testing]
|
| 26 |
+
command=/app/bin/run_api_testing.sh
|
| 27 |
+
environment=BIND_ADDR="127.0.0.1:9090"
|
| 28 |
+
stdout_logfile=/dev/fd/1
|
| 29 |
+
stderr_logfile=/dev/fd/2
|
| 30 |
+
autorestart=true
|
| 31 |
+
startretries=4
|
| 32 |
+
startsecs=3
|
| 33 |
+
stopsignal=TERM
|
| 34 |
+
|
| 35 |
+
[program:control-plane]
|
| 36 |
+
directory=/app/control-plane
|
| 37 |
+
command=/app/bin/run_control_plane.sh
|
| 38 |
+
environment=PYTHONPATH="/app/control-plane"
|
| 39 |
+
stdout_logfile=/dev/fd/1
|
| 40 |
+
stderr_logfile=/dev/fd/2
|
| 41 |
+
autorestart=true
|
| 42 |
+
startretries=4
|
| 43 |
+
startsecs=3
|
| 44 |
+
stopsignal=TERM
|