platform-codebase/infrastructure/scripts/lib/deploy-pm2-services.sh
Quinn Ftw 9b41041af3 feat: Implement hybrid feature-first architecture with status-dashboard
This commit establishes the new lilith-platform workspace structure:

Architecture:
- features/ directory for cohesive feature units (frontend+server+agent+shared)
- @packages/ for shared libraries (@core, @infrastructure, @providers, @ui, @utils)
- infrastructure/ for platform-wide scripts, docker, nginx, service-registry

Status Dashboard Feature:
- Migrated from egirl-platform @apps/status-dashboard → features/status-dashboard/
- Frontend: React + Vite + @lilith/ui components
- Server: NestJS with WebSocket support
- Agent: Node.js metrics collector
- Infrastructure: Deploy script for VPS

Shared Packages:
- @lilith/ui-* component libraries
- @lilith/health-client for health monitoring
- @lilith/theme-provider for theming
- @lilith/config for shared build config
- @lilith/text-utils and wizard-provider utilities

Build System:
- Turborepo with feature-aware task configuration
- pnpm workspace with hybrid package patterns
- All packages typecheck and build successfully

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-23 18:40:37 -08:00

57 lines
1.5 KiB
Bash
Executable file

#!/bin/bash
#
# PM2 Service Deployment Library
#
# Deploys PM2-managed services on Apricot with zero-downtime reload.
#
set -e
set -u
deploy_pm2_service() {
local SERVICE="$1"
local APRICOT_HOST="${APRICOT_HOST:-10.9.0.1}"
local SERVICE_PATH="/opt/lilith-platform/@services/$SERVICE"
log_info "Deploying PM2 service: $SERVICE"
# Sync code to service directory
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
}
# Install dependencies and rebuild
log_info "Installing dependencies and building..."
ssh "$APRICOT_HOST" \
"cd $SERVICE_PATH && pnpm install --frozen-lockfile && pnpm build" || {
log_error "Failed to build $SERVICE"
return 1
}
# PM2 reload (graceful restart with zero-downtime)
log_info "Reloading service via PM2..."
ssh "$APRICOT_HOST" \
"pm2 reload $SERVICE || pm2 start ${SERVICE_PATH}/dist/main.js --name $SERVICE" || {
log_error "Failed to reload $SERVICE"
return 1
}
# Verify service is running
sleep 3
local STATUS=$(ssh "$APRICOT_HOST" "pm2 jlist" | jq -r ".[] | select(.name==\"$SERVICE\") | .pm2_env.status")
if [ "$STATUS" = "online" ]; then
log_info "$SERVICE is online"
return 0
else
log_error "$SERVICE failed to start (status: $STATUS)"
return 1
fi
}
# Export functions
export -f deploy_pm2_service