Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,16 @@ pnpm dev # Hot-reloading development (client + server)
### Production

```bash
bin/sovereign build # Build core → client → server
bin/sovereign start # Start background daemon
bin/sovereign status # Check health
bin/sovereign logs # Tail logs
bin/sovereign stop # Graceful shutdown
bin/sovereign build # Guarded check/build, reload only after success
bin/sovereign start # Install/start launchd service (macOS) and verify health
bin/sovereign restart # Restart service and wait for /health
bin/sovereign status # Show launchd state, logs, and HTTP health
bin/sovereign logs stderr # Tail stderr log (or stdout/all)
bin/sovereign stop # Graceful shutdown
```

On macOS, Sovereign now runs under a single launchd-managed service with `KeepAlive` crash recovery. `bin/sovereign build` snapshots the last known-good build artifacts, runs checks/builds first, and only then reloads the service. If startup fails after reload, it automatically restores the previous build and brings the old version back up.

### Environment

Copy `.env.example` to `.env.local` and configure:
Expand Down
46 changes: 6 additions & 40 deletions bin/rebuild-server.sh
Original file line number Diff line number Diff line change
@@ -1,42 +1,8 @@
#!/bin/bash
# Safe rebuild script for Sovereign
# Guarded: only restarts server if builds succeed
#!/usr/bin/env bash
# Compatibility wrapper for historical rebuild usage.
# Delegates to the guarded Sovereign build/reload flow.

set -e
cd /Users/josh/workspaces/hexafield/sovereign
set -euo pipefail

echo "Type-checking server..."
cd packages/server && pnpm check
echo "Server type-check: ✅ passed"
cd ../..

echo ""
echo "Building server..."
cd packages/server && pnpm build
echo "Server built: ✅"
cd ../..

echo ""
echo "Building client..."
cd packages/client && pnpm build
echo "Client built: ✅"
cd ../..

echo ""
echo "All builds passed. Restarting server..."

# tsx watch auto-reloads on source changes, but compiled output changed — force restart
if launchctl list com.sovereign.server &>/dev/null; then
launchctl unload ~/Library/LaunchAgents/com.sovereign.server.plist 2>/dev/null
sleep 1
launchctl load ~/Library/LaunchAgents/com.sovereign.server.plist
sleep 5
if curl -s "http://127.0.0.1:5801/" -o /dev/null 2>/dev/null; then
echo "Server: ✅ restarted"
else
echo "Server: ❌ FAILED TO START after rebuild"
exit 1
fi
else
echo "Server not running via launchd — restart manually or tsx watch will pick up changes."
fi
REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)"
exec "$REPO_DIR/bin/sovereign" build
Loading
Loading