tijiaodaim
This commit is contained in:
1 parent
1bf1fc6512
commit
6eda572f31
2 files changed
+174
-2
No files matched your search
@@ -5,6 +5,10 @@ source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/env.sh"
|
||||
|
||||
PID_FILE="${PID_DIR}/backend.pid"
|
||||
LOG_FILE="${LOG_DIR}/backend.log"
|
||||
BACKEND_VENDOR_DIR="${BACKEND_VENDOR_DIR:-${BACKEND_DIR}/.deer-flow/python-vendor}"
|
||||
BACKEND_WHEELHOUSE="${BACKEND_WHEELHOUSE:-${BACKEND_DIR}/wheelhouse}"
|
||||
BACKEND_INSTALL_DEPS="${BACKEND_INSTALL_DEPS:-1}"
|
||||
BACKEND_PIP_PACKAGES="${BACKEND_PIP_PACKAGES:-croniter==6.2.2 langgraph-checkpoint-postgres==3.0.5 psycopg==3.3.3 psycopg-binary==3.3.3 psycopg-pool==3.3.0 orjson==3.11.9 tzdata==2026.2}"
|
||||
|
||||
if is_running "${PID_FILE}"; then
|
||||
echo "Backend is already running (pid $(cat "${PID_FILE}"))."
|
||||
@@ -17,16 +21,41 @@ rm -f "${PID_FILE}"
|
||||
echo "Starting backend..."
|
||||
echo "Log: ${LOG_FILE}"
|
||||
|
||||
mkdir -p "${BACKEND_VENDOR_DIR}"
|
||||
|
||||
if [[ "${BACKEND_INSTALL_DEPS}" != "0" ]]; then
|
||||
if ! (
|
||||
cd "${BACKEND_DIR}" && \
|
||||
PYTHONPATH=".:${BACKEND_VENDOR_DIR}${PYTHONPATH:+:${PYTHONPATH}}" \
|
||||
uv run --no-sync python -c "import croniter; import psycopg; import psycopg_pool; import langgraph.checkpoint.postgres; import langgraph.store.postgres"
|
||||
) >/dev/null 2>&1; then
|
||||
if [[ ! -d "${BACKEND_WHEELHOUSE}" ]]; then
|
||||
echo "ERROR: wheelhouse not found: ${BACKEND_WHEELHOUSE}" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "Installing backend runtime deps into ${BACKEND_VENDOR_DIR}"
|
||||
(
|
||||
cd "${BACKEND_DIR}" && \
|
||||
uv pip install \
|
||||
--target "${BACKEND_VENDOR_DIR}" \
|
||||
--no-deps \
|
||||
--no-index \
|
||||
--find-links "${BACKEND_WHEELHOUSE}" \
|
||||
${BACKEND_PIP_PACKAGES}
|
||||
)
|
||||
fi
|
||||
fi
|
||||
|
||||
setsid bash -c '
|
||||
cd "$0" || exit 1
|
||||
exec env \
|
||||
GATEWAY_CORS_ORIGINS="$1" \
|
||||
PYTHONPATH=. \
|
||||
PYTHONPATH=".:$4${PYTHONPATH:+:${PYTHONPATH}}" \
|
||||
uv run uvicorn app.gateway.app:app \
|
||||
--host "$2" \
|
||||
--port "$3" \
|
||||
--reload
|
||||
' "${BACKEND_DIR}" "${GATEWAY_CORS_ORIGINS}" "${BACKEND_HOST}" "${BACKEND_PORT}" \
|
||||
' "${BACKEND_DIR}" "${GATEWAY_CORS_ORIGINS}" "${BACKEND_HOST}" "${BACKEND_PORT}" "${BACKEND_VENDOR_DIR}" \
|
||||
>"${LOG_FILE}" 2>&1 &
|
||||
|
||||
echo "$!" >"${PID_FILE}"
|
||||
|
||||
Reference in new issue
Block a user