Files
clinera-site/pi-worker/deploy.sh
T
Azreen Jamal 19420cc01d feat: add pi-worker service - autonomous Asana task executor & project improvement agent
- Asana REST API client for task polling, section management, and commenting
- Pi CLI executor for running tasks with specialist agent teams
- Task loop: polls Asana To Do/Pi Worker sections, executes tasks, reports results
- Improvement loop: rotates through 8 improvement categories (code quality, security, docs, testing, etc)
- Health server on :8787
- File-based mutex locks with stale lock detection
- Docker + docker-compose deployment config
- deploy.sh for one-command deployment to cr-server-new via SSH/Incus
2026-03-06 15:26:13 +08:00

47 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Deploy pi-worker to cr-server-new
SERVER="root@159.195.60.33"
CONTAINER="cr-server-new"
DEPLOY_PATH="/opt/pi-worker"
echo "🚀 Deploying Pi Worker to cr-server-new..."
# Sync files to server
echo "📦 Syncing files..."
rsync -avz --exclude=node_modules --exclude=logs --exclude=.env \
./ ${SERVER}:${DEPLOY_PATH}/
# Copy .env if it exists locally
if [ -f .env ]; then
echo "🔐 Syncing .env..."
rsync -avz .env ${SERVER}:${DEPLOY_PATH}/.env
fi
# Push into container and build
echo "🔨 Building inside cr-server-new..."
ssh ${SERVER} << 'EOF'
incus file push -r /root/pi-worker cr-server-new/opt/
incus exec cr-server-new -- bash -c "
cd /opt/pi-worker
bun install
echo '✅ Dependencies installed'
"
EOF
echo "🏃 Starting Pi Worker..."
ssh ${SERVER} << 'EOF'
incus exec cr-server-new -- bash -c "
cd /opt/pi-worker
# Stop existing instance
pkill -f 'bun.*pi-worker' || true
# Start in background
nohup bun run src/index.ts > /var/log/pi-worker.log 2>&1 &
echo '✅ Pi Worker started (PID: $!)'
"
EOF
echo "🎉 Deployment complete!"
echo "Health check: ssh ${SERVER} 'incus exec ${CONTAINER} -- curl -s http://localhost:8787/health'"