Root workspace configuration with 4 submodules: - codebase/ → lilith/platform-codebase - deployments/ → lilith/platform-deployments - tooling/ → lilith/platform-tooling - docs/ → lilith/platform-docs Tracks workspace config (package.json, turbo.json, bunfig.toml), CI workflows (.forgejo/), dev scripts, and instructions. Each submodule retains its own history and remote.
73 lines
2.1 KiB
Bash
Executable file
73 lines
2.1 KiB
Bash
Executable file
#!/bin/bash
|
|
#
|
|
# Python ML Service Deployment Library
|
|
#
|
|
# Deploys Python ML services on Apricot via systemd.
|
|
#
|
|
# Usage:
|
|
# source scripts/lib/deploy/python.sh
|
|
# deploy_python_service "ml-watermarking-python"
|
|
#
|
|
|
|
set -e
|
|
set -u
|
|
|
|
deploy_python_service() {
|
|
local SERVICE="$1"
|
|
local APRICOT_HOST="${APRICOT_HOST:-10.9.0.1}"
|
|
local SERVICE_PATH="/opt/lilith-platform/@services/$SERVICE"
|
|
|
|
log_info "Deploying Python service: $SERVICE"
|
|
|
|
# Sync code
|
|
log_info "Syncing code to $APRICOT_HOST..."
|
|
rsync -avz --delete \
|
|
"@services/$SERVICE/" \
|
|
"${APRICOT_HOST}:${SERVICE_PATH}/" || {
|
|
log_error "Failed to sync code for $SERVICE"
|
|
return 1
|
|
}
|
|
|
|
# Restart service via systemd
|
|
log_info "Restarting systemd service..."
|
|
ssh "$APRICOT_HOST" \
|
|
"sudo systemctl restart lilith-$SERVICE" || {
|
|
log_warn "systemctl restart failed, trying direct python restart..."
|
|
# Fallback: restart via supervisor or direct process
|
|
ssh "$APRICOT_HOST" \
|
|
"pkill -f $SERVICE && cd $SERVICE_PATH && nohup python -m uvicorn src.api.main:app --host 0.0.0.0 --port $(get_python_service_port "$SERVICE") > /tmp/$SERVICE.log 2>&1 &"
|
|
}
|
|
|
|
# Wait for service to be ready
|
|
sleep 5
|
|
|
|
# Health check
|
|
local PORT=$(get_python_service_port "$SERVICE")
|
|
local HEALTH=$(ssh "$APRICOT_HOST" \
|
|
"curl -sf http://localhost:${PORT}/health" 2>/dev/null | jq -r '.status' 2>/dev/null)
|
|
|
|
if [ "$HEALTH" = "healthy" ] || [ "$HEALTH" = "ok" ]; then
|
|
log_info "✅ $SERVICE is healthy"
|
|
return 0
|
|
else
|
|
log_error "$SERVICE health check failed"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
get_python_service_port() {
|
|
case "$1" in
|
|
ml-watermarking-python) echo "8000" ;;
|
|
ml-moderation-python) echo "8001" ;;
|
|
ml-content-generator-python) echo "8004" ;;
|
|
ml-truth-python) echo "8005" ;;
|
|
ml-image-generation-python) echo "8006" ;;
|
|
ml-job-scheduler-python) echo "8007" ;;
|
|
ml-i18n) echo "8003" ;;
|
|
*) echo "8000" ;;
|
|
esac
|
|
}
|
|
|
|
# Export functions
|
|
export -f deploy_python_service
|
|
export -f get_python_service_port
|