new changes
This commit is contained in:
@@ -100,7 +100,8 @@ install_base_packages() {
|
||||
apt)
|
||||
apt-get update -qq
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
git python3 python3-venv python3-pip redis-server nginx curl ca-certificates
|
||||
git python3 python3-venv python3-pip python3-dev build-essential \
|
||||
redis-server nginx curl ca-certificates
|
||||
;;
|
||||
dnf|yum)
|
||||
if [ "$PKG" = dnf ]; then
|
||||
@@ -119,27 +120,29 @@ install_base_packages() {
|
||||
esac
|
||||
}
|
||||
|
||||
ensure_python_min_311() {
|
||||
if command -v python3.11 >/dev/null 2>&1; then
|
||||
if python3.11 -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 11) else 1)' 2>/dev/null; then
|
||||
PYTHON_CMD=python3.11
|
||||
return 0
|
||||
fi
|
||||
# Default dist Python (3.10+ on Ubuntu 22.04) is enough; otherwise install 3.11 from apt.
|
||||
ensure_python_for_backend() {
|
||||
if [ -n "${PYTHON_CMD:-}" ]; then
|
||||
return 0
|
||||
fi
|
||||
if python3 -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 11) else 1)' 2>/dev/null; then
|
||||
if python3 -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 10) else 1)' 2>/dev/null; then
|
||||
PYTHON_CMD=python3
|
||||
return 0
|
||||
fi
|
||||
if command -v python3.11 >/dev/null 2>&1 && python3.11 -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 10) else 1)' 2>/dev/null; then
|
||||
PYTHON_CMD=python3.11
|
||||
return 0
|
||||
fi
|
||||
if [ "$PKG" = apt ]; then
|
||||
echo "Python 3.11+ required for the backend; installing python3.11 from apt..."
|
||||
echo "Python 3.10+ required for the backend; installing python3.11 from apt..."
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y python3.11 python3.11-venv python3.11-dev || {
|
||||
echo "Could not install python3.11. Use Ubuntu 24.04+, enable universe, or install Python 3.11+ manually."
|
||||
echo "Could not install python3.11. Enable universe or install Python 3.10+ manually."
|
||||
exit 1
|
||||
}
|
||||
PYTHON_CMD=python3.11
|
||||
return 0
|
||||
fi
|
||||
echo "Python 3.11+ required. Current: $(python3 -V 2>/dev/null || echo 'python3 missing')"
|
||||
echo "Python 3.10+ required. Current: $(python3 -V 2>/dev/null || echo 'python3 missing')"
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -189,6 +192,7 @@ stage_source_to_install_path() {
|
||||
}
|
||||
|
||||
install_base_packages
|
||||
ensure_python_for_backend
|
||||
ensure_node_18_plus
|
||||
|
||||
echo ""
|
||||
@@ -234,6 +238,10 @@ cd "$INSTALL_PATH/backend"
|
||||
# shellcheck source=/dev/null
|
||||
source venv/bin/activate
|
||||
pip install -q -r requirements.txt
|
||||
./venv/bin/python -c "import app.main" || {
|
||||
echo "ERROR: Backend failed to import (see traceback above). Check Python version and requirements."
|
||||
exit 1
|
||||
}
|
||||
python scripts/seed_admin.py
|
||||
deactivate
|
||||
|
||||
@@ -281,6 +289,7 @@ Type=simple
|
||||
User=root
|
||||
WorkingDirectory=$INSTALL_PATH/backend
|
||||
Environment="PATH=$INSTALL_PATH/backend/venv/bin:\$PATH"
|
||||
Environment=PYTHONUNBUFFERED=1
|
||||
ExecStart=$INSTALL_PATH/backend/venv/bin/uvicorn app.main:app --host 127.0.0.1 --port $BACKEND_PORT
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
@@ -294,7 +303,7 @@ systemctl enable "$SYSTEMD_UNIT"
|
||||
systemctl restart "$SYSTEMD_UNIT" || systemctl start "$SYSTEMD_UNIT"
|
||||
|
||||
backend_ok=0
|
||||
for _ in {1..40}; do
|
||||
for _ in {1..120}; do
|
||||
if curl -sfS --max-time 2 "http://127.0.0.1:${BACKEND_PORT}/api/health" >/dev/null 2>&1; then
|
||||
backend_ok=1
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user