Skip to content

Commit edc994f

Browse files
author
Saravana Kumar Rajendran
committed
Simplify container startup by dropping supervisord
1 parent cf35871 commit edc994f

3 files changed

Lines changed: 41 additions & 31 deletions

File tree

deploy/supervisord.conf

Lines changed: 0 additions & 24 deletions
This file was deleted.

docker/build_and_push.Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ ARG FRONTEND2_DIR=frontend2-static
8585

8686
RUN apt-get update \
8787
&& apt-get upgrade -y \
88-
&& apt-get install -y curl git libpq5 gnupg nginx supervisor \
88+
&& apt-get install -y curl git libpq5 gnupg nginx \
8989
&& curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
9090
&& apt-get install -y nodejs \
9191
&& apt-get clean \
@@ -99,12 +99,10 @@ ENV PATH="/app/.venv/bin:$PATH"
9999

100100
COPY ${FRONTEND2_DIR}/ /usr/share/nginx/frontend2/
101101
COPY deploy/nginx-extra.conf /etc/nginx/conf.d/frontend2.conf.template
102-
COPY deploy/supervisord.conf /etc/supervisor/conf.d/langflow.conf
103102
COPY scripts/start_with_nginx.sh /app/scripts/start_with_nginx.sh
104103

105104
RUN chmod +x /app/scripts/start_with_nginx.sh \
106-
&& rm /etc/nginx/conf.d/default.conf \
107-
&& mkdir -p /var/log/supervisor
105+
&& rm /etc/nginx/conf.d/default.conf
108106

109107
LABEL org.opencontainers.image.title=langflow
110108
LABEL org.opencontainers.image.authors=['Langflow']

scripts/start_with_nginx.sh

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#!/bin/sh
2-
set -e
2+
set -eu
33

44
BACKEND_HOST="${LANGFLOW_HOST:-0.0.0.0}"
55
PUBLIC_PORT="${LANGFLOW_PORT:-7860}"
66
BACKEND_PORT="${LANGFLOW_BACKEND_PORT:-7861}"
77

88
export LANGFLOW_HOST="$BACKEND_HOST"
9-
export LANGFLOW_PORT="$PUBLIC_PORT"
109
export LANGFLOW_BACKEND_PORT="$BACKEND_PORT"
10+
export LANGFLOW_PUBLIC_PORT="$PUBLIC_PORT"
11+
export LANGFLOW_PORT="$BACKEND_PORT"
1112

1213
CONFIG_TEMPLATE="/etc/nginx/conf.d/frontend2.conf.template"
1314
CONFIG_PATH="/etc/nginx/conf.d/frontend2.conf"
@@ -19,4 +20,39 @@ if [ -f "$CONFIG_TEMPLATE" ]; then
1920
"$CONFIG_TEMPLATE" > "$CONFIG_PATH"
2021
fi
2122

22-
exec supervisord -c /etc/supervisor/conf.d/langflow.conf
23+
cleanup() {
24+
if [ -n "${BACKEND_PID:-}" ] && kill -0 "$BACKEND_PID" 2>/dev/null; then
25+
kill "$BACKEND_PID"
26+
fi
27+
if [ -n "${NGINX_PID:-}" ] && kill -0 "$NGINX_PID" 2>/dev/null; then
28+
kill "$NGINX_PID"
29+
fi
30+
}
31+
32+
trap 'cleanup' INT TERM
33+
34+
/usr/sbin/runuser -u user -- langflow run --host "$BACKEND_HOST" --port "$BACKEND_PORT" --log-level info &
35+
BACKEND_PID=$!
36+
37+
/usr/sbin/nginx -g "daemon off;" &
38+
NGINX_PID=$!
39+
40+
while :; do
41+
if ! kill -0 "$BACKEND_PID" 2>/dev/null; then
42+
wait "$BACKEND_PID"
43+
EXIT_CODE=$?
44+
cleanup
45+
wait "$NGINX_PID" 2>/dev/null || true
46+
exit "$EXIT_CODE"
47+
fi
48+
49+
if ! kill -0 "$NGINX_PID" 2>/dev/null; then
50+
wait "$NGINX_PID"
51+
EXIT_CODE=$?
52+
cleanup
53+
wait "$BACKEND_PID" 2>/dev/null || true
54+
exit "$EXIT_CODE"
55+
fi
56+
57+
sleep 1
58+
done

0 commit comments

Comments
 (0)