wilfredwake 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +52 -0
- package/LICENSE +21 -0
- package/QUICKSTART.md +400 -0
- package/README.md +831 -0
- package/bin/cli.js +133 -0
- package/index.js +222 -0
- package/package.json +41 -0
- package/src/cli/commands/health.js +238 -0
- package/src/cli/commands/init.js +192 -0
- package/src/cli/commands/status.js +180 -0
- package/src/cli/commands/wake.js +182 -0
- package/src/cli/config.js +263 -0
- package/src/config/services.yaml +49 -0
- package/src/orchestrator/orchestrator.js +397 -0
- package/src/orchestrator/registry.js +283 -0
- package/src/orchestrator/server.js +402 -0
- package/src/shared/colors.js +154 -0
- package/src/shared/logger.js +224 -0
- package/tests/cli.test.js +328 -0
package/README.md
ADDED
|
@@ -0,0 +1,831 @@
|
|
|
1
|
+
# wilfredwake 🌅
|
|
2
|
+
|
|
3
|
+
**CLI Tool for Multi-Developer Development Environment Wake & Status Management**
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 📖 Table of Contents
|
|
8
|
+
|
|
9
|
+
- [Purpose](#purpose)
|
|
10
|
+
- [Quick Start](#quick-start)
|
|
11
|
+
- [Features](#features)
|
|
12
|
+
- [Installation](#installation)
|
|
13
|
+
- [Configuration](#configuration)
|
|
14
|
+
- [Commands](#commands)
|
|
15
|
+
- [Architecture](#architecture)
|
|
16
|
+
- [Service Registry](#service-registry)
|
|
17
|
+
- [Multi-Developer Support](#multi-developer-support)
|
|
18
|
+
- [Examples](#examples)
|
|
19
|
+
- [Troubleshooting](#troubleshooting)
|
|
20
|
+
- [Future Enhancements](#future-enhancements)
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Purpose
|
|
25
|
+
|
|
26
|
+
**wilfredwake** is a CLI tool for managing sleeping development services in distributed systems. It enables developers to:
|
|
27
|
+
|
|
28
|
+
✅ **Wake services on demand** - Start services when needed
|
|
29
|
+
✅ **Check readiness** - Validate services are healthy before use
|
|
30
|
+
✅ **Respect dependencies** - Wake services in correct order
|
|
31
|
+
✅ **Multi-developer support** - Shared orchestrator ensures consistent state
|
|
32
|
+
✅ **Avoid workflow blocks** - Cold-start and Render-like sleeping environments no longer interrupt development
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Quick Start
|
|
37
|
+
|
|
38
|
+
### 1. Initialize Configuration
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Run setup wizard
|
|
42
|
+
wilfredwake init
|
|
43
|
+
|
|
44
|
+
# Provide orchestrator URL (default: http://localhost:3000)
|
|
45
|
+
# Select environment (dev, staging, prod)
|
|
46
|
+
# Optionally provide API token
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 2. Check Service Status
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Check all services
|
|
53
|
+
wilfredwake status
|
|
54
|
+
|
|
55
|
+
# Check specific service
|
|
56
|
+
wilfredwake status auth
|
|
57
|
+
|
|
58
|
+
# Output as JSON
|
|
59
|
+
wilfredwake status --format json
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 3. Wake Services
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Wake all services
|
|
66
|
+
wilfredwake wake all
|
|
67
|
+
|
|
68
|
+
# Wake specific service
|
|
69
|
+
wilfredwake wake auth
|
|
70
|
+
|
|
71
|
+
# Wake service group
|
|
72
|
+
wilfredwake wake payments
|
|
73
|
+
|
|
74
|
+
# Don't wait for readiness
|
|
75
|
+
wilfredwake wake all --no-wait
|
|
76
|
+
|
|
77
|
+
# Custom timeout (in seconds)
|
|
78
|
+
wilfredwake wake all --timeout 600
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 4. Check Health
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# Health check all services
|
|
85
|
+
wilfredwake health
|
|
86
|
+
|
|
87
|
+
# Check specific service
|
|
88
|
+
wilfredwake health auth
|
|
89
|
+
|
|
90
|
+
# No waking, just diagnostics
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Features
|
|
96
|
+
|
|
97
|
+
### 🎯 Core Features
|
|
98
|
+
|
|
99
|
+
- **Dependency-Aware Waking** - Services wake in correct dependency order
|
|
100
|
+
- **Health Monitoring** - Continuous polling until services are ready
|
|
101
|
+
- **Multi-Environment** - Manage dev, staging, and prod separately
|
|
102
|
+
- **Configuration-Driven** - No code changes to add new services
|
|
103
|
+
- **Human-Readable Output** - Color-coded status with visual hierarchy
|
|
104
|
+
- **Error Handling** - Clear error messages with guidance
|
|
105
|
+
- **Timeout Management** - Configurable timeouts with exponential backoff
|
|
106
|
+
|
|
107
|
+
### 🎨 Output Features
|
|
108
|
+
|
|
109
|
+
- **Color-Coded Status** - Different colors for different service states
|
|
110
|
+
- **Table Format** - Clear, organized service status display
|
|
111
|
+
- **JSON Export** - Machine-readable output for automation
|
|
112
|
+
- **Progress Indicators** - Animated spinners during operations
|
|
113
|
+
- **Duration Tracking** - See how long operations take
|
|
114
|
+
|
|
115
|
+
### 🔒 Multi-Developer Features
|
|
116
|
+
|
|
117
|
+
- **Per-User Tokens** - Identify developers in orchestrator logs
|
|
118
|
+
- **Shared State** - Orchestrator is single source of truth
|
|
119
|
+
- **Concurrent Operations** - Multiple developers can wake services
|
|
120
|
+
- **Safe Waking** - No interference between developers
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Installation
|
|
125
|
+
|
|
126
|
+
### NPM (Global)
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# Install globally
|
|
130
|
+
npm install -g wilfredwake
|
|
131
|
+
|
|
132
|
+
# Verify installation
|
|
133
|
+
wilfredwake --version
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### NPM (Local Development)
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# Clone repository
|
|
140
|
+
git clone https://github.com/wilfred/wilfredwake.git
|
|
141
|
+
cd wilfredwake
|
|
142
|
+
|
|
143
|
+
# Install dependencies
|
|
144
|
+
npm install
|
|
145
|
+
|
|
146
|
+
# Link for local testing
|
|
147
|
+
npm link
|
|
148
|
+
|
|
149
|
+
# Run CLI
|
|
150
|
+
wilfredwake --help
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### From Source
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# Using git clone
|
|
157
|
+
git clone https://github.com/wilfred/wilfredwake.git
|
|
158
|
+
cd wilfredwake
|
|
159
|
+
|
|
160
|
+
# Install dependencies
|
|
161
|
+
npm install
|
|
162
|
+
|
|
163
|
+
# Start CLI (development)
|
|
164
|
+
npm start
|
|
165
|
+
|
|
166
|
+
# Start orchestrator (development)
|
|
167
|
+
npm run orchestrator
|
|
168
|
+
|
|
169
|
+
# Watch mode for development
|
|
170
|
+
npm run dev
|
|
171
|
+
npm run orchestrator:dev
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Configuration
|
|
177
|
+
|
|
178
|
+
### First-Time Setup
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
wilfredwake init
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
This creates `~/.wilfredwake/config.json` with:
|
|
185
|
+
|
|
186
|
+
```json
|
|
187
|
+
{
|
|
188
|
+
"orchestratorUrl": "http://localhost:3000",
|
|
189
|
+
"token": "your-api-token",
|
|
190
|
+
"environment": "dev",
|
|
191
|
+
"preferences": {
|
|
192
|
+
"outputFormat": "table",
|
|
193
|
+
"verbose": false,
|
|
194
|
+
"autoWait": true,
|
|
195
|
+
"timeout": 300,
|
|
196
|
+
"colorOutput": true,
|
|
197
|
+
"notifyOnComplete": false
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Configuration Options
|
|
203
|
+
|
|
204
|
+
| Option | Type | Default | Description |
|
|
205
|
+
|--------|------|---------|-------------|
|
|
206
|
+
| `orchestratorUrl` | string | `http://localhost:3000` | Orchestrator backend URL |
|
|
207
|
+
| `token` | string | `null` | API token for authentication |
|
|
208
|
+
| `environment` | string | `dev` | Default environment (dev, staging, prod) |
|
|
209
|
+
| `preferences.outputFormat` | string | `table` | Output format (table or json) |
|
|
210
|
+
| `preferences.verbose` | boolean | `false` | Enable debug output |
|
|
211
|
+
| `preferences.autoWait` | boolean | `true` | Wait for services to be ready |
|
|
212
|
+
| `preferences.timeout` | number | `300` | Default timeout in seconds |
|
|
213
|
+
| `preferences.colorOutput` | boolean | `true` | Enable colored output |
|
|
214
|
+
|
|
215
|
+
### Environment Variables
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
# Orchestrator settings
|
|
219
|
+
export PORT=3000
|
|
220
|
+
export REGISTRY_FILE=/path/to/services.yaml
|
|
221
|
+
export NODE_ENV=production
|
|
222
|
+
export REQUIRE_AUTH=true
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Commands
|
|
228
|
+
|
|
229
|
+
### `wilfredwake init`
|
|
230
|
+
|
|
231
|
+
Initialize wilfredwake configuration.
|
|
232
|
+
|
|
233
|
+
**Options:**
|
|
234
|
+
- `-o, --orchestrator <url>` - Orchestrator URL (default: http://localhost:3000)
|
|
235
|
+
- `-t, --token <token>` - Developer API token
|
|
236
|
+
|
|
237
|
+
**Example:**
|
|
238
|
+
```bash
|
|
239
|
+
wilfredwake init --orchestrator http://my-orchestrator:3000 --token abc123
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
### `wilfredwake status [service]`
|
|
245
|
+
|
|
246
|
+
Check status of services.
|
|
247
|
+
|
|
248
|
+
**Options:**
|
|
249
|
+
- `-e, --env <environment>` - Environment (dev, staging, prod) [default: dev]
|
|
250
|
+
- `-f, --format <format>` - Output format: table or json [default: table]
|
|
251
|
+
|
|
252
|
+
**Examples:**
|
|
253
|
+
```bash
|
|
254
|
+
# All services
|
|
255
|
+
wilfredwake status
|
|
256
|
+
|
|
257
|
+
# Specific service
|
|
258
|
+
wilfredwake status auth
|
|
259
|
+
|
|
260
|
+
# Different environment
|
|
261
|
+
wilfredwake status -e staging
|
|
262
|
+
|
|
263
|
+
# JSON format
|
|
264
|
+
wilfredwake status --format json
|
|
265
|
+
|
|
266
|
+
# Combine options
|
|
267
|
+
wilfredwake status payment-producer -e staging --format json
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
**Output:**
|
|
271
|
+
```
|
|
272
|
+
📊 Services (DEV)
|
|
273
|
+
|
|
274
|
+
SERVICE STATUS URL UPTIME
|
|
275
|
+
auth READY https://auth-dev... 2h 30m
|
|
276
|
+
payment-producer SLEEPING https://pay-prod... N/A
|
|
277
|
+
payment-consumer READY https://pay-cons... 1h 15m
|
|
278
|
+
|
|
279
|
+
Summary
|
|
280
|
+
✓ Ready: 2 | ⚫ Sleeping: 1 | ⟳ Waking: 0 | ✗ Failed: 0
|
|
281
|
+
Total: 3 services
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
### `wilfredwake wake <target>`
|
|
287
|
+
|
|
288
|
+
Wake services on demand.
|
|
289
|
+
|
|
290
|
+
**Target Options:**
|
|
291
|
+
- `all` - Wake all services
|
|
292
|
+
- `<service-name>` - Wake specific service
|
|
293
|
+
- `<group-name>` - Wake service group
|
|
294
|
+
|
|
295
|
+
**Options:**
|
|
296
|
+
- `-e, --env <environment>` - Environment (dev, staging, prod) [default: dev]
|
|
297
|
+
- `--no-wait` - Don't wait for services to be ready
|
|
298
|
+
- `--timeout <seconds>` - Timeout for readiness [default: 300]
|
|
299
|
+
|
|
300
|
+
**Examples:**
|
|
301
|
+
```bash
|
|
302
|
+
# Wake all services
|
|
303
|
+
wilfredwake wake all
|
|
304
|
+
|
|
305
|
+
# Wake specific service (with dependencies)
|
|
306
|
+
wilfredwake wake payment-consumer
|
|
307
|
+
|
|
308
|
+
# Wake service group
|
|
309
|
+
wilfredwake wake payments
|
|
310
|
+
|
|
311
|
+
# Different environment
|
|
312
|
+
wilfredwake wake all -e staging
|
|
313
|
+
|
|
314
|
+
# Custom timeout
|
|
315
|
+
wilfredwake wake all --timeout 600
|
|
316
|
+
|
|
317
|
+
# Don't wait for readiness
|
|
318
|
+
wilfredwake wake all --no-wait
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
**Output:**
|
|
322
|
+
```
|
|
323
|
+
🌅 Wake Operation Results
|
|
324
|
+
|
|
325
|
+
Timeline:
|
|
326
|
+
│ ✓ auth (1.2s)
|
|
327
|
+
│ ✓ payment-producer (3.4s)
|
|
328
|
+
└ ✓ payment-consumer (2.1s)
|
|
329
|
+
|
|
330
|
+
✓ Wake Complete
|
|
331
|
+
|
|
332
|
+
✓ Ready: 3
|
|
333
|
+
⏱ Total Time: 6.7s
|
|
334
|
+
✓ All services are ready!
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
339
|
+
### `wilfredwake health [service]`
|
|
340
|
+
|
|
341
|
+
Check health status (no waking).
|
|
342
|
+
|
|
343
|
+
**Options:**
|
|
344
|
+
- `-e, --env <environment>` - Environment (dev, staging, prod) [default: dev]
|
|
345
|
+
|
|
346
|
+
**Examples:**
|
|
347
|
+
```bash
|
|
348
|
+
# Check all
|
|
349
|
+
wilfredwake health
|
|
350
|
+
|
|
351
|
+
# Check specific
|
|
352
|
+
wilfredwake health auth
|
|
353
|
+
|
|
354
|
+
# Different environment
|
|
355
|
+
wilfredwake health -e prod
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
**Output:**
|
|
359
|
+
```
|
|
360
|
+
💓 Health Status (DEV)
|
|
361
|
+
|
|
362
|
+
💚 auth (ready)
|
|
363
|
+
URL: https://auth-dev.onrender.com
|
|
364
|
+
Response time: 42ms
|
|
365
|
+
Last checked: 10:30:15 AM
|
|
366
|
+
Status code: 200
|
|
367
|
+
|
|
368
|
+
😴 payment-producer (sleeping)
|
|
369
|
+
URL: https://pay-prod-dev.onrender.com
|
|
370
|
+
Error: Service Unavailable (503)
|
|
371
|
+
|
|
372
|
+
Summary
|
|
373
|
+
Total services: 2
|
|
374
|
+
✓ Healthy: 1
|
|
375
|
+
✗ Unhealthy: 1
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
---
|
|
379
|
+
|
|
380
|
+
## Architecture
|
|
381
|
+
|
|
382
|
+
### System Design
|
|
383
|
+
|
|
384
|
+
```
|
|
385
|
+
┌──────────────────┐
|
|
386
|
+
│ Developer CLI │ ← You run: wilfredwake wake all
|
|
387
|
+
│ (this tool) │
|
|
388
|
+
└────────┬─────────┘
|
|
389
|
+
│ HTTP REST API
|
|
390
|
+
↓
|
|
391
|
+
┌──────────────────────────────┐
|
|
392
|
+
│ Orchestrator (always-on) │ ← Backend service
|
|
393
|
+
│ • Registry Manager │
|
|
394
|
+
│ • Wake Orchestrator │
|
|
395
|
+
│ • State Tracking │
|
|
396
|
+
└────────┬──────────────────────┘
|
|
397
|
+
│ Wake requests
|
|
398
|
+
↓
|
|
399
|
+
┌──────────────────┐
|
|
400
|
+
│ Microservices │ ← /health and /wake endpoints
|
|
401
|
+
│ • auth │
|
|
402
|
+
│ • payment-prod │
|
|
403
|
+
│ • payment-cons │
|
|
404
|
+
│ • api-gateway │
|
|
405
|
+
└──────────────────┘
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
### Components
|
|
409
|
+
|
|
410
|
+
#### 1. CLI (`src/cli/`)
|
|
411
|
+
|
|
412
|
+
Local interface developers interact with.
|
|
413
|
+
|
|
414
|
+
- **commands/** - Command implementations (init, status, wake, health)
|
|
415
|
+
- **config.js** - Configuration management
|
|
416
|
+
- **utils.js** - CLI utilities and helpers
|
|
417
|
+
|
|
418
|
+
#### 2. Orchestrator (`src/orchestrator/`)
|
|
419
|
+
|
|
420
|
+
Always-on backend service.
|
|
421
|
+
|
|
422
|
+
- **server.js** - Express.js API server
|
|
423
|
+
- **registry.js** - Service registry loader and validator
|
|
424
|
+
- **orchestrator.js** - Wake logic and dependency ordering
|
|
425
|
+
|
|
426
|
+
#### 3. Shared (`src/shared/`)
|
|
427
|
+
|
|
428
|
+
Common utilities and modules.
|
|
429
|
+
|
|
430
|
+
- **colors.js** - Color schemes and formatting
|
|
431
|
+
- **logger.js** - Logging and utilities
|
|
432
|
+
- **errors.js** - Error definitions
|
|
433
|
+
|
|
434
|
+
#### 4. Configuration (`src/config/`)
|
|
435
|
+
|
|
436
|
+
Service definitions and registry.
|
|
437
|
+
|
|
438
|
+
- **services.yaml** - Service registry (single source of truth)
|
|
439
|
+
|
|
440
|
+
---
|
|
441
|
+
|
|
442
|
+
## Service Registry
|
|
443
|
+
|
|
444
|
+
### Format
|
|
445
|
+
|
|
446
|
+
The service registry is a YAML file defining all services, environments, and dependencies.
|
|
447
|
+
|
|
448
|
+
**Location:** `src/config/services.yaml`
|
|
449
|
+
|
|
450
|
+
### Structure
|
|
451
|
+
|
|
452
|
+
```yaml
|
|
453
|
+
services:
|
|
454
|
+
dev: # Environment name
|
|
455
|
+
auth: # Service name
|
|
456
|
+
url: https://... # Base URL
|
|
457
|
+
health: /health # Health check endpoint
|
|
458
|
+
wake: /wake # Wake endpoint
|
|
459
|
+
dependsOn: [] # Dependencies (empty = no deps)
|
|
460
|
+
description: "..." # Service description
|
|
461
|
+
|
|
462
|
+
payment-consumer:
|
|
463
|
+
url: https://...
|
|
464
|
+
health: /health
|
|
465
|
+
wake: /wake
|
|
466
|
+
dependsOn: [auth] # Depends on auth service
|
|
467
|
+
description: "..."
|
|
468
|
+
|
|
469
|
+
groups: # Service groups (optional)
|
|
470
|
+
payments:
|
|
471
|
+
services: [payment-producer, payment-consumer]
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
### Adding a New Service
|
|
475
|
+
|
|
476
|
+
1. **Edit `src/config/services.yaml`**
|
|
477
|
+
|
|
478
|
+
```yaml
|
|
479
|
+
services:
|
|
480
|
+
dev:
|
|
481
|
+
my-new-service:
|
|
482
|
+
url: https://my-service-dev.onrender.com
|
|
483
|
+
health: /health
|
|
484
|
+
wake: /wake
|
|
485
|
+
dependsOn: [auth] # List dependencies
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
2. **Reload registry**
|
|
489
|
+
|
|
490
|
+
```bash
|
|
491
|
+
# Orchestrator reloads automatically (watch mode)
|
|
492
|
+
# Or manually:
|
|
493
|
+
curl -X POST http://localhost:3000/api/reload
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
3. **Use immediately**
|
|
497
|
+
|
|
498
|
+
```bash
|
|
499
|
+
wilfredwake wake my-new-service
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
### Service Endpoints
|
|
503
|
+
|
|
504
|
+
Every service must implement:
|
|
505
|
+
|
|
506
|
+
**Health Check Endpoint** (GET)
|
|
507
|
+
```http
|
|
508
|
+
GET /health
|
|
509
|
+
Response: HTTP 200 OK
|
|
510
|
+
{
|
|
511
|
+
"status": "ok",
|
|
512
|
+
"uptime": 3600
|
|
513
|
+
}
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
**Wake Endpoint** (POST)
|
|
517
|
+
```http
|
|
518
|
+
POST /wake
|
|
519
|
+
Response: HTTP 200 OK or 204 No Content
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
### Dependencies
|
|
523
|
+
|
|
524
|
+
Dependencies determine wake order using topological sort.
|
|
525
|
+
|
|
526
|
+
**Example:**
|
|
527
|
+
```yaml
|
|
528
|
+
auth:
|
|
529
|
+
dependsOn: [] # Wakes first
|
|
530
|
+
|
|
531
|
+
payment-producer:
|
|
532
|
+
dependsOn: [auth] # Wakes after auth
|
|
533
|
+
|
|
534
|
+
payment-consumer:
|
|
535
|
+
dependsOn: # Wakes after both
|
|
536
|
+
- payment-producer
|
|
537
|
+
- database
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
**Wake order when `wilfredwake wake all`:**
|
|
541
|
+
1. ✓ auth (no dependencies)
|
|
542
|
+
2. ✓ database (no dependencies)
|
|
543
|
+
3. ✓ payment-producer (after auth)
|
|
544
|
+
4. ✓ payment-consumer (after payment-producer and database)
|
|
545
|
+
|
|
546
|
+
---
|
|
547
|
+
|
|
548
|
+
## Multi-Developer Support
|
|
549
|
+
|
|
550
|
+
### How It Works
|
|
551
|
+
|
|
552
|
+
1. **Each developer runs CLI locally** - Installs and configures wilfredwake
|
|
553
|
+
2. **One shared orchestrator** - Backend service is always-on
|
|
554
|
+
3. **Per-developer tokens** - Identifies developer in logs
|
|
555
|
+
4. **Centralized state** - Orchestrator is single source of truth
|
|
556
|
+
|
|
557
|
+
### Benefits
|
|
558
|
+
|
|
559
|
+
- ✅ No local hardcoding of services
|
|
560
|
+
- ✅ Consistent state across all developers
|
|
561
|
+
- ✅ One source of truth for service definitions
|
|
562
|
+
- ✅ Safe concurrent operations
|
|
563
|
+
- ✅ Easy to update services (just update registry)
|
|
564
|
+
|
|
565
|
+
### Setup
|
|
566
|
+
|
|
567
|
+
**Developer A:**
|
|
568
|
+
```bash
|
|
569
|
+
wilfredwake init --orchestrator http://orchestrator.company.com:3000
|
|
570
|
+
# Creates ~/.wilfredwake/config.json with unique user ID
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
**Developer B:**
|
|
574
|
+
```bash
|
|
575
|
+
wilfredwake init --orchestrator http://orchestrator.company.com:3000
|
|
576
|
+
# Different config file, same orchestrator
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
Both developers now use the same service definitions and state.
|
|
580
|
+
|
|
581
|
+
---
|
|
582
|
+
|
|
583
|
+
## Examples
|
|
584
|
+
|
|
585
|
+
### Example 1: Wake All Services
|
|
586
|
+
|
|
587
|
+
```bash
|
|
588
|
+
$ wilfredwake wake all -e dev
|
|
589
|
+
|
|
590
|
+
🌅 Wake Operation Results
|
|
591
|
+
|
|
592
|
+
Timeline:
|
|
593
|
+
│ ✓ auth (1.2s)
|
|
594
|
+
│ ✓ database (0.8s)
|
|
595
|
+
│ ✓ payment-producer (2.1s)
|
|
596
|
+
└ ✓ payment-consumer (1.9s)
|
|
597
|
+
|
|
598
|
+
✓ Wake Complete
|
|
599
|
+
|
|
600
|
+
✓ Ready: 4
|
|
601
|
+
⏱ Total Time: 6.0s
|
|
602
|
+
✓ All services are ready!
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
### Example 2: Wake Single Service with Dependencies
|
|
606
|
+
|
|
607
|
+
```bash
|
|
608
|
+
$ wilfredwake wake payment-consumer
|
|
609
|
+
|
|
610
|
+
🌅 Wake Operation Results
|
|
611
|
+
|
|
612
|
+
Timeline:
|
|
613
|
+
│ ✓ auth (1.2s)
|
|
614
|
+
│ ✓ payment-producer (2.1s)
|
|
615
|
+
└ ✓ payment-consumer (1.9s)
|
|
616
|
+
|
|
617
|
+
✓ Wake Complete
|
|
618
|
+
|
|
619
|
+
✓ Ready: 3
|
|
620
|
+
⏱ Total Time: 5.2s
|
|
621
|
+
✓ All services are ready!
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
### Example 3: Check Status in Different Environments
|
|
625
|
+
|
|
626
|
+
```bash
|
|
627
|
+
# Development
|
|
628
|
+
$ wilfredwake status -e dev
|
|
629
|
+
|
|
630
|
+
# Staging
|
|
631
|
+
$ wilfredwake status -e staging
|
|
632
|
+
|
|
633
|
+
# Production
|
|
634
|
+
$ wilfredwake status -e prod
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
### Example 4: JSON Output for Automation
|
|
638
|
+
|
|
639
|
+
```bash
|
|
640
|
+
$ wilfredwake status --format json
|
|
641
|
+
|
|
642
|
+
[
|
|
643
|
+
{
|
|
644
|
+
"name": "auth",
|
|
645
|
+
"status": "ready",
|
|
646
|
+
"url": "https://auth-dev.onrender.com",
|
|
647
|
+
"uptime": "2h 30m"
|
|
648
|
+
},
|
|
649
|
+
...
|
|
650
|
+
]
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
### Example 5: Health Check Without Waking
|
|
654
|
+
|
|
655
|
+
```bash
|
|
656
|
+
$ wilfredwake health
|
|
657
|
+
|
|
658
|
+
💓 Health Status (DEV)
|
|
659
|
+
|
|
660
|
+
💚 auth (ready)
|
|
661
|
+
😴 payment-producer (sleeping)
|
|
662
|
+
💚 api-gateway (ready)
|
|
663
|
+
|
|
664
|
+
Summary
|
|
665
|
+
Total services: 3
|
|
666
|
+
✓ Healthy: 2
|
|
667
|
+
✗ Unhealthy: 1
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
### Example 6: Custom Timeout
|
|
671
|
+
|
|
672
|
+
```bash
|
|
673
|
+
# 10 minute timeout
|
|
674
|
+
$ wilfredwake wake all --timeout 600
|
|
675
|
+
|
|
676
|
+
# Don't wait (fire and forget)
|
|
677
|
+
$ wilfredwake wake all --no-wait
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
---
|
|
681
|
+
|
|
682
|
+
## Troubleshooting
|
|
683
|
+
|
|
684
|
+
### "Could not connect to orchestrator"
|
|
685
|
+
|
|
686
|
+
**Problem:** CLI can't reach the orchestrator backend.
|
|
687
|
+
|
|
688
|
+
**Solution:**
|
|
689
|
+
1. Check orchestrator is running: `curl http://localhost:3000/health`
|
|
690
|
+
2. Verify orchestrator URL in config: `cat ~/.wilfredwake/config.json`
|
|
691
|
+
3. Check firewall/networking: Can you reach the URL?
|
|
692
|
+
|
|
693
|
+
```bash
|
|
694
|
+
# Reinitialize with correct URL
|
|
695
|
+
wilfredwake init --orchestrator http://correct-orchestrator:3000
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
### Service times out during wake
|
|
699
|
+
|
|
700
|
+
**Problem:** Service takes too long to wake.
|
|
701
|
+
|
|
702
|
+
**Solution:** Increase timeout
|
|
703
|
+
|
|
704
|
+
```bash
|
|
705
|
+
# Default is 300 seconds (5 minutes)
|
|
706
|
+
wilfredwake wake all --timeout 900 # 15 minutes
|
|
707
|
+
```
|
|
708
|
+
|
|
709
|
+
### Circular dependency detected
|
|
710
|
+
|
|
711
|
+
**Problem:** Services have circular dependencies.
|
|
712
|
+
|
|
713
|
+
**Solution:** Fix in `services.yaml`
|
|
714
|
+
|
|
715
|
+
```yaml
|
|
716
|
+
# ❌ BAD - Circular dependency
|
|
717
|
+
auth:
|
|
718
|
+
dependsOn: [payment-producer]
|
|
719
|
+
|
|
720
|
+
payment-producer:
|
|
721
|
+
dependsOn: [auth]
|
|
722
|
+
|
|
723
|
+
# ✅ GOOD - Linear dependency
|
|
724
|
+
auth:
|
|
725
|
+
dependsOn: []
|
|
726
|
+
|
|
727
|
+
payment-producer:
|
|
728
|
+
dependsOn: [auth]
|
|
729
|
+
```
|
|
730
|
+
|
|
731
|
+
### Some services fail to wake
|
|
732
|
+
|
|
733
|
+
**Problem:** One or more services don't respond.
|
|
734
|
+
|
|
735
|
+
**Solution:**
|
|
736
|
+
1. Check service URLs in registry
|
|
737
|
+
2. Verify services have `/health` and `/wake` endpoints
|
|
738
|
+
3. Check service logs
|
|
739
|
+
4. Try individual service wake
|
|
740
|
+
|
|
741
|
+
```bash
|
|
742
|
+
# Try single service
|
|
743
|
+
wilfredwake wake auth
|
|
744
|
+
|
|
745
|
+
# Check health
|
|
746
|
+
wilfredwake health auth
|
|
747
|
+
|
|
748
|
+
# Check orchestrator logs
|
|
749
|
+
```
|
|
750
|
+
|
|
751
|
+
### Service shows as "sleeping" but should be ready
|
|
752
|
+
|
|
753
|
+
**Problem:** Service is responding with 503.
|
|
754
|
+
|
|
755
|
+
**Solution:** Service may actually be asleep. Wake it:
|
|
756
|
+
|
|
757
|
+
```bash
|
|
758
|
+
wilfredwake wake <service-name>
|
|
759
|
+
```
|
|
760
|
+
|
|
761
|
+
---
|
|
762
|
+
|
|
763
|
+
## Future Enhancements
|
|
764
|
+
|
|
765
|
+
### Phase 1 (Current)
|
|
766
|
+
✅ Basic CLI commands
|
|
767
|
+
✅ Service registry
|
|
768
|
+
✅ Orchestrator backend
|
|
769
|
+
✅ Dependency ordering
|
|
770
|
+
|
|
771
|
+
### Phase 2
|
|
772
|
+
🔄 CLI auto-completion
|
|
773
|
+
🔄 Hot reload of service registry
|
|
774
|
+
🔄 Web UI for visualization
|
|
775
|
+
🔄 Scoped groups and tagging
|
|
776
|
+
|
|
777
|
+
### Phase 3
|
|
778
|
+
🔲 Slack/email notifications
|
|
779
|
+
🔲 Service metrics and performance tracking
|
|
780
|
+
🔲 Health monitoring and alerting
|
|
781
|
+
🔲 Multi-user authentication
|
|
782
|
+
|
|
783
|
+
### Phase 4
|
|
784
|
+
🔲 Kubernetes integration
|
|
785
|
+
🔲 Service lifecycle management (pause, stop, restart)
|
|
786
|
+
🔲 GraphQL API for advanced queries
|
|
787
|
+
🔲 gRPC support for services
|
|
788
|
+
|
|
789
|
+
---
|
|
790
|
+
|
|
791
|
+
## Contributing
|
|
792
|
+
|
|
793
|
+
We welcome contributions! Please:
|
|
794
|
+
|
|
795
|
+
1. Fork the repository
|
|
796
|
+
2. Create a feature branch
|
|
797
|
+
3. Make your changes
|
|
798
|
+
4. Add tests
|
|
799
|
+
5. Submit a pull request
|
|
800
|
+
|
|
801
|
+
---
|
|
802
|
+
|
|
803
|
+
## License
|
|
804
|
+
|
|
805
|
+
MIT License - See LICENSE file for details
|
|
806
|
+
|
|
807
|
+
---
|
|
808
|
+
|
|
809
|
+
## Support
|
|
810
|
+
|
|
811
|
+
For issues, questions, or suggestions:
|
|
812
|
+
|
|
813
|
+
- 📝 [Open an issue](https://github.com/wilfred/wilfredwake/issues)
|
|
814
|
+
- 💬 [Discussions](https://github.com/wilfred/wilfredwake/discussions)
|
|
815
|
+
- 📧 Email: wilfred@wilfredwake.dev
|
|
816
|
+
|
|
817
|
+
---
|
|
818
|
+
|
|
819
|
+
## References & Inspiration
|
|
820
|
+
|
|
821
|
+
- Render sleeping service behavior
|
|
822
|
+
- Kubernetes orchestration concepts
|
|
823
|
+
- Terraform infrastructure as code
|
|
824
|
+
- Internal DevOps tooling best practices
|
|
825
|
+
- Multi-environment configuration strategies
|
|
826
|
+
|
|
827
|
+
---
|
|
828
|
+
|
|
829
|
+
**Made with ❤️ by Wilfred Wake**
|
|
830
|
+
|
|
831
|
+
*Keep your development environment awake and ready!* 🌅
|