claw-spawn
Complete Digital Ocean VPS provisioning and OpenClaw bot orchestration service.
This repo supports:
- Standalone microservice (
claw-spawn-server) - Embedding into a larger Axum server via
claw_spawn::server::router(...)
π Super Quick Start (One Command)
Just run make and you're ready to go:
# Clone the repository
# Run everything (creates .env, sets up DB, runs migrations, builds, and starts server)
That's it! The server will start on http://localhost:8080
Then edit .env and add your DigitalOcean API token:
# Edit the .env file
CLAW_DIGITALOCEAN_TOKEN=your_actual_token_here
π Makefile Commands
The Makefile provides easy commands for development:
| Command | Description |
|---|---|
make |
Full setup and start (default) |
make dev |
Quick dev mode with hot reload |
make setup |
Initial environment setup only |
make db |
Create database |
make migrate |
Run database migrations |
make build |
Build release binary |
make run |
Start the server |
make test |
Run all tests |
make clean |
Clean build artifacts |
make docker-run |
Run with Docker Compose |
make help |
Show all available commands |
π§ Manual Setup (If You Prefer)
Prerequisites
- Rust/Cargo: https://rustup.rs/
- PostgreSQL:
brew install postgresql(macOS) orapt-get install postgresql - sqlx-cli:
cargo install sqlx-cli
1. Set Environment Variables
2. Setup Database
# Create database
# Run migrations
3. Build and Run
# Build release binary
# Start server
π³ Docker Quick Start
# Start with Docker Compose (includes PostgreSQL)
# Or manually:
The Docker setup includes:
- PostgreSQL database (auto-created)
- Automatic migrations on startup
- Server exposed on port 8080
π¦ Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
CLAW_DATABASE_URL |
Yes | - | PostgreSQL connection string |
CLAW_DIGITALOCEAN_TOKEN |
Yes | - | DigitalOcean API token |
CLAW_ENCRYPTION_KEY |
Yes | - | Base64-encoded 32-byte key |
CLAW_SERVER_HOST |
No | 0.0.0.0 |
Server bind address |
CLAW_SERVER_PORT |
No | 8080 |
Server port |
CLAW_OPENCLAW_IMAGE |
No | ubuntu-22-04-x64 |
DO droplet image |
CLAW_CONTROL_PLANE_URL |
No | https://api.cedros.io |
Bot control-plane base URL |
CLAW_CUSTOMIZER_REPO_URL |
No | https://github.com/janebot2026/janebot-cli.git |
Public git repo for workspace customizer |
CLAW_CUSTOMIZER_REF |
No | pinned SHA | Git ref (tag/branch/SHA) to checkout for reproducible bootstrap |
CLAW_CUSTOMIZER_WORKSPACE_DIR |
No | /opt/openclaw/workspace |
Workspace directory on droplet |
CLAW_CUSTOMIZER_AGENT_NAME |
No | Jane |
Agent name passed to customizer |
CLAW_CUSTOMIZER_OWNER_NAME |
No | Cedros |
Owner name passed to customizer |
CLAW_CUSTOMIZER_SKIP_QMD |
No | true |
Skip QMD install at droplet bootstrap |
CLAW_CUSTOMIZER_SKIP_CRON |
No | true |
Skip OpenClaw cron install at droplet bootstrap |
CLAW_CUSTOMIZER_SKIP_GIT |
No | true |
Skip git init at droplet bootstrap |
CLAW_CUSTOMIZER_SKIP_HEARTBEAT |
No | true |
Skip heartbeat install at droplet bootstrap |
πͺ Droplet Bootstrap Notes
- The droplet must be able to reach
CLAW_CONTROL_PLANE_URLover HTTPS. If you runclaw-spawnlocally, you typically need a tunnel (ngrok/cloudflared) until you have a live URL. - Workspace customization (janebot-cli) runs once and writes:
- Marker:
/opt/openclaw/.customizer_ran - Status:
/opt/openclaw/customizer_status.txt
- Marker:
π§© Embedded Usage (Integrate Into Larger Axum Server)
claw-spawn supports a dual architecture:
- Standalone microservice via the
claw-spawn-serverbinary - Embedded router via
claw_spawn::server::router(...)
Example (host app nests this service under /spawn):
use Router;
use AppConfig;
use ;
use PgPool;
let cfg = from_env?;
let pool = connect.await?;
let state = build_state_with_pool.await?;
let app = new.nest;
π¦ Crate Usage
Add to Cargo.toml:
[]
# Core library only (no Axum server/router)
= { = "0.1", = false }
Or, if you want the embeddable HTTP server/router:
[]
= { = "0.1", = ["server"] }
π― API Usage Examples
Create a Bot
Response:
Check Bot Status
Bot Actions
# Pause
# Resume
# Destroy
π API Endpoints
App Endpoints
POST /bots- Create botGET /bots/:id- Get bot detailsGET /accounts/:id/bots- List account botsPOST /bots/:id/actions- pause/resume/redeploy/destroy
Bot Agent Endpoints
GET /bot/:id/config- Pull configPOST /bot/:id/config_ack- Acknowledge configPOST /bot/:id/heartbeat- Health checkPOST /bot/register- Initial registration
ποΈ Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β claw-spawn β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Axum HTTP Server β β
β β ββββββββββββββββ ββββββββββββββββ βββββββββββββββββ β
β β β App API β β Bot API β β Health ββ β
β β β (/bots/*) β β (/bot/*) β β (/health) ββ β
β β ββββββββββββββββ ββββββββββββββββ βββββββββββββββββ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Application Layer β β
β β ββββββββββββββββ ββββββββββββββββ β β
β β βProvisioning β β BotLifecycle β β
β β β Service β β Service β β
β β ββββββββββββββββ ββββββββββββββββ β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Infrastructure Layer β β
β β ββββββββββββββββ ββββββββββββββββ βββββββββββββββ β
β β βDigitalOcean β βPostgreSQL β β Crypto ββ β
β β β Client β βRepositories β β(AES-256) ββ β
β β ββββββββββββββββ ββββββββββββββββ βββββββββββββββ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββ
β DigitalOcean VPS β
β βββββββββββββββββββ β
β β OpenClaw Bot β β
β β Agent β β
β βββββββββββββββββββ β
βββββββββββββββββββββββββ
π Security
- AES-256-GCM encryption for all secrets (LLM API keys)
- Per-bot registration tokens for authentication
- Firewall rules on droplets (default deny inbound)
- No secrets in logs - all sensitive data redacted
π Documentation
- Setup: See Super Quick Start and Manual Setup
- API Reference: See API Usage Examples
- Architecture: See Architecture section
π οΈ Development
# Quick dev cycle
# Run tests
# Check code
# Format code
# Lint
π Database Migrations
# Create migration
# Run migrations
# Check status
# Revert last
π§Ή Troubleshooting
"sqlx-cli not found"
"Database connection failed"
# Check PostgreSQL is running
"Port 8080 already in use"
# Edit .env and change CLAW_SERVER_PORT
CLAW_SERVER_PORT=8081
π€ Library Usage
Use as a library in your Rust project:
use ;
// See README.md for full example
π License
MIT