Deployment Guide

Deploy PULSE to production

Deployment Guide

Deploy PULSE to Cloudflare Workers in production.

Prerequisites

Deployment Environments

PULSE supports three deployment environments:

Step 1: Configure wrangler.toml

Update wrangler.toml with your Cloudflare credentials:

name = "pulse-app"
main = "src/index.ts"
account_id = "YOUR_ACCOUNT_ID"

[[d1_databases]]
binding = "DB"
database_name = "pulse_analytics"
database_id = "YOUR_DATABASE_ID"

[[kv_namespaces]]
binding = "CACHE"
id = "YOUR_KV_NAMESPACE_ID"

[triggers]
crons = ["0 * * * *"]  # Hourly

Step 2: Set Secrets

# Production API key
wrangler secret put API_SECRET --env production

# Optional: Datadog API key
wrangler secret put DATADOG_API_KEY --env production

Step 3: Build

npm run build

Verify no TypeScript errors:

npx tsc --noEmit

Step 4: Test

Run tests before deploying:

npm run test          # Unit tests
npm run test:e2e      # E2E tests
npm run test:load     # Load tests (optional)

Step 5: Deploy

Staging Deployment

npm run deploy:staging

Production Deployment

npm run deploy:blue

Canary Deployment (10% traffic)

npm run deploy:canary

Step 6: Verify Deployment

Check deployment status:

curl https://api.example.com/health
# Expected: { "status": "ok", "timestamp": ... }

curl https://api.example.com/health/ready
# Expected: { "status": "ready", "dependencies": { ... } }

Blue-Green Deployment Strategy

PULSE uses blue-green deployments:

Rollback

If issues occur:

npm run deploy:rollback

This deploys the last stable blue version.

Environment-Specific Configuration

Development

npm run dev  # Local testing at http://localhost:8787

Staging

wrangler deploy --env staging
# Routes to staging.api.example.com

Production

wrangler deploy --env production
# Routes to api.example.com

Database Migrations

Before deploying, apply any new migrations:

# View migrations
ls -la migrations/

# Apply migrations (before deployment)
wrangler d1 execute pulse_analytics --batch migrations/*.sql

Monitoring Deployment

Monitor deployment health:

# View logs
wrangler tail

# Get deployment info
wrangler deployments list

# Rollback if needed
wrangler rollback

Post-Deployment Checklist

After deploying to production:

Performance Baseline

After deployment, monitor:

MetricTargetMonitor Tool
API latency (p95)<500msCloudflare Analytics
Error rate<0.1%Cloudflare Analytics
Database queriesStableKV cache hit rate >80%
WebSocket connections<1msCloudflare Analytics

Troubleshooting Deployment

Deploy Fails with “Database not found"

# Verify database exists
wrangler d1 list

# Check wrangler.toml has correct database_id

"Unauthorized” After Deploy

# Verify API secret is set
wrangler secret list --env production

# Re-set if needed
wrangler secret put API_SECRET --env production

High Latency After Deploy

# Check cache is working
curl https://api.example.com/api/v1/stats \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "x-custom-debug: true"

# View KV cache hit rate in dashboard

Next Steps

Last updated: April 3, 2026