# ✅ START/STOP/LAUNCH COMPLETE ## Summary Bitcoin Core and all docker-compose apps can now be controlled from the "My Apps" UI. Start, stop, and launch buttons are fully functional with the Rust backend. ## What Was Added ### Backend RPC Methods Added three new RPC endpoints to `/Users/dorian/Projects/archy/core/archipelago/src/api/rpc.rs`: 1. **`package.start`** - Starts a docker-compose container 2. **`package.stop`** - Stops a docker-compose container 3. **`package.restart`** - Restarts a docker-compose container These methods: - Take a package `id` (e.g., `"bitcoin"`) - Convert it to container name (e.g., `"archy-bitcoin"`) - Execute Docker CLI commands directly - Return success/error to frontend ## Testing ### Stop Bitcoin ```bash curl -X POST http://localhost:5959/rpc/v1 \ -H "Content-Type: application/json" \ -d '{"method": "package.stop", "params": {"id": "bitcoin"}}' ``` **Result:** ```json {"result":null,"error":null} ``` **Docker status:** ``` archy-bitcoin Exited (0) 4 seconds ago ``` ### Start Bitcoin ```bash curl -X POST http://localhost:5959/rpc/v1 \ -H "Content-Type: application/json" \ -d '{"method": "package.start", "params": {"id": "bitcoin"}}' ``` **Result:** ```json {"result":null,"error":null} ``` **Docker status:** ``` archy-bitcoin Up 2 seconds ``` ## How It Works ### 1. Frontend Button Click User clicks "Stop" button in "My Apps" ### 2. RPC Call Frontend sends: ```json { "method": "package.stop", "params": {"id": "bitcoin"} } ``` ### 3. Backend Processing ```rust async fn handle_package_stop(params) { let package_id = params.get("id"); // "bitcoin" let container_name = format!("archy-{}", package_id); // "archy-bitcoin" // Execute: docker stop archy-bitcoin tokio::process::Command::new("docker") .arg("stop") .arg(&container_name) .output() .await?; } ``` ### 4. Docker Execution ```bash docker stop archy-bitcoin ``` ### 5. Live Update Backend's 5-second poll detects the stopped container and broadcasts the state change via WebSocket to the UI. ## UI Behavior ### My Apps Page **Running State:** - Green badge showing "running" - "Stop" button enabled - "Launch" button enabled **Stopped State:** - Gray badge showing "stopped" - "Start" button enabled - "Launch" button disabled ### Launch Functionality When "Launch" is clicked: 1. Opens `lan-address` from package data 2. For Bitcoin Core: `http://localhost:18443` 3. Opens in new browser tab ## Supported Apps All docker-compose apps support start/stop/launch: | App | Container Name | Port | Status | |-----|----------------|------|--------| | Bitcoin Core | `archy-bitcoin` | 18443 | ✅ Tested | | BTCPay Server | `archy-btcpay` | 23000 | ✅ Ready | | Home Assistant | `archy-homeassistant` | 8123 | ✅ Ready | | Grafana | `archy-grafana` | 3000 | ✅ Ready | | All others | `archy-*` | Various | ✅ Ready | ## Architecture Flow ``` ┌─────────────────────────────────────────┐ │ Vue.js UI │ │ - Stop/Start buttons │ │ - Launch button │ └─────────────┬───────────────────────────┘ │ RPC: package.start/stop ┌─────────────▼───────────────────────────┐ │ Rust Backend │ │ - Receives RPC call │ │ - Converts package ID to container name │ │ - Executes Docker command │ └─────────────┬───────────────────────────┘ │ docker start/stop ┌─────────────▼───────────────────────────┐ │ Docker Engine │ │ - Stops/starts container │ │ - Container state changes │ └─────────────┬───────────────────────────┘ │ Poll every 5s ┌─────────────▼───────────────────────────┐ │ Docker Scanner │ │ - Detects state change │ │ - Updates package-data │ │ - Broadcasts via WebSocket │ └─────────────┬───────────────────────────┘ │ WebSocket update ┌─────────────▼───────────────────────────┐ │ Vue.js UI (auto-updates) │ │ - Button states update │ │ - Badge color changes │ └──────────────────────────────────────────┘ ``` ## Development Testing ### Start Full Stack ```bash ./scripts/dev-start.sh # Choose option 2 (Full stack) ``` ### Open UI ``` http://localhost:8101 (or 8100 if available) ``` ### Navigate to My Apps 1. See Bitcoin Core running 2. Click "Stop" → Status changes to "stopped" within 5 seconds 3. Click "Start" → Status changes to "running" within 5 seconds 4. Click "Launch" → Opens http://localhost:18443 ## Files Modified 1. **`core/archipelago/src/api/rpc.rs`** - Added `package.start`, `package.stop`, `package.restart` endpoints - Direct Docker CLI integration - Parameter parsing and error handling ## Current Status ✅ **Start/Stop**: Fully functional ✅ **Launch**: Working with correct URLs ✅ **Live Updates**: 5-second polling active ✅ **Error Handling**: Proper error messages ✅ **All Apps**: Every docker-compose app supported ## Next: Start All Apps To see more apps in "My Apps": ```bash docker compose up -d ``` All will be controllable from the UI! --- **Backend must be running for controls to work:** ```bash cd /Users/dorian/Projects/archy/core ARCHIPELAGO_DATA_DIR=/tmp/archipelago-dev \ ARCHIPELAGO_DEV_MODE=true \ ARCHIPELAGO_CONTAINER_RUNTIME=docker \ ./target/release/archipelago ```