new changes

This commit is contained in:
Niranjan
2026-04-07 04:11:59 +05:30
parent e2f2d5cc38
commit 493b4f6556
44 changed files with 23 additions and 13 deletions

View File

@@ -13,7 +13,6 @@ from collections import defaultdict
from typing import Annotated, Any, Literal, Optional, Union from typing import Annotated, Any, Literal, Optional, Union
from urllib.parse import urlparse from urllib.parse import urlparse
import asyncssh
from fastapi import APIRouter, HTTPException, Request, WebSocket from fastapi import APIRouter, HTTPException, Request, WebSocket
from pydantic import BaseModel, Field, field_validator from pydantic import BaseModel, Field, field_validator
@@ -198,6 +197,8 @@ async def create_job(body: CreateJobRequest, request: Request):
auth_payload = body.auth auth_payload = body.auth
async def runner() -> None: async def runner() -> None:
import asyncssh
async with _jobs_lock: async with _jobs_lock:
job = _jobs.get(job_id) job = _jobs.get(job_id)
if not job: if not job:

Binary file not shown.

View File

@@ -100,7 +100,8 @@ install_base_packages() {
apt) apt)
apt-get update -qq apt-get update -qq
DEBIAN_FRONTEND=noninteractive apt-get install -y \ 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) dnf|yum)
if [ "$PKG" = dnf ]; then if [ "$PKG" = dnf ]; then
@@ -119,27 +120,29 @@ install_base_packages() {
esac esac
} }
ensure_python_min_311() { # Default dist Python (3.10+ on Ubuntu 22.04) is enough; otherwise install 3.11 from apt.
if command -v python3.11 >/dev/null 2>&1; then ensure_python_for_backend() {
if python3.11 -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 11) else 1)' 2>/dev/null; then if [ -n "${PYTHON_CMD:-}" ]; then
PYTHON_CMD=python3.11 return 0
return 0
fi
fi 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 PYTHON_CMD=python3
return 0 return 0
fi 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 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 || { 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 exit 1
} }
PYTHON_CMD=python3.11 PYTHON_CMD=python3.11
return 0 return 0
fi 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 exit 1
} }
@@ -189,6 +192,7 @@ stage_source_to_install_path() {
} }
install_base_packages install_base_packages
ensure_python_for_backend
ensure_node_18_plus ensure_node_18_plus
echo "" echo ""
@@ -234,6 +238,10 @@ cd "$INSTALL_PATH/backend"
# shellcheck source=/dev/null # shellcheck source=/dev/null
source venv/bin/activate source venv/bin/activate
pip install -q -r requirements.txt 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 python scripts/seed_admin.py
deactivate deactivate
@@ -281,6 +289,7 @@ Type=simple
User=root User=root
WorkingDirectory=$INSTALL_PATH/backend WorkingDirectory=$INSTALL_PATH/backend
Environment="PATH=$INSTALL_PATH/backend/venv/bin:\$PATH" 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 ExecStart=$INSTALL_PATH/backend/venv/bin/uvicorn app.main:app --host 127.0.0.1 --port $BACKEND_PORT
Restart=always Restart=always
RestartSec=3 RestartSec=3
@@ -294,7 +303,7 @@ systemctl enable "$SYSTEMD_UNIT"
systemctl restart "$SYSTEMD_UNIT" || systemctl start "$SYSTEMD_UNIT" systemctl restart "$SYSTEMD_UNIT" || systemctl start "$SYSTEMD_UNIT"
backend_ok=0 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 if curl -sfS --max-time 2 "http://127.0.0.1:${BACKEND_PORT}/api/health" >/dev/null 2>&1; then
backend_ok=1 backend_ok=1
break break