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/.env.example
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# ╔═══════════════════════════════════════════════════════════════╗
|
|
2
|
+
# ║ WILFREDWAKE ENVIRONMENT VARIABLES ║
|
|
3
|
+
# ║ Configuration for orchestrator and CLI ║
|
|
4
|
+
# ╚═══════════════════════════════════════════════════════════════╝
|
|
5
|
+
|
|
6
|
+
# ═══════════════════════════════════════════════════════════════
|
|
7
|
+
# ORCHESTRATOR SERVER CONFIGURATION
|
|
8
|
+
# ═══════════════════════════════════════════════════════════════
|
|
9
|
+
|
|
10
|
+
# Port to run orchestrator on
|
|
11
|
+
PORT=3000
|
|
12
|
+
|
|
13
|
+
# Path to service registry file
|
|
14
|
+
REGISTRY_FILE=./src/config/services.yaml
|
|
15
|
+
|
|
16
|
+
# Node environment
|
|
17
|
+
NODE_ENV=production
|
|
18
|
+
|
|
19
|
+
# ═══════════════════════════════════════════════════════════════
|
|
20
|
+
# AUTHENTICATION
|
|
21
|
+
# ═══════════════════════════════════════════════════════════════
|
|
22
|
+
|
|
23
|
+
# Require authentication tokens
|
|
24
|
+
REQUIRE_AUTH=false
|
|
25
|
+
|
|
26
|
+
# ═══════════════════════════════════════════════════════════════
|
|
27
|
+
# LOGGING & DEBUG
|
|
28
|
+
# ═══════════════════════════════════════════════════════════════
|
|
29
|
+
|
|
30
|
+
# Enable debug logging
|
|
31
|
+
DEBUG=false
|
|
32
|
+
|
|
33
|
+
# Log level (error, warn, info, debug)
|
|
34
|
+
LOG_LEVEL=info
|
|
35
|
+
|
|
36
|
+
# ═══════════════════════════════════════════════════════════════
|
|
37
|
+
# SERVICE HEALTH CHECK CONFIGURATION
|
|
38
|
+
# ═══════════════════════════════════════════════════════════════
|
|
39
|
+
|
|
40
|
+
# Health check timeout (milliseconds)
|
|
41
|
+
HEALTH_CHECK_TIMEOUT=5000
|
|
42
|
+
|
|
43
|
+
# Health check poll interval (milliseconds)
|
|
44
|
+
HEALTH_CHECK_INTERVAL=2000
|
|
45
|
+
|
|
46
|
+
# ═══════════════════════════════════════════════════════════════
|
|
47
|
+
# NOTES
|
|
48
|
+
# ═══════════════════════════════════════════════════════════════
|
|
49
|
+
# 1. Copy this file to .env.local for local development
|
|
50
|
+
# 2. Never commit .env.local with sensitive values
|
|
51
|
+
# 3. Use .env.example for version control
|
|
52
|
+
# 4. Environment variables override default values
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Wilfred Wake
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/QUICKSTART.md
ADDED
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
# 🌅 wilfredwake Quick Start Guide
|
|
2
|
+
|
|
3
|
+
This guide will get you up and running with wilfredwake in 5 minutes.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Prerequisites
|
|
8
|
+
|
|
9
|
+
- **Node.js** 18.0.0 or higher
|
|
10
|
+
- **npm** or **yarn**
|
|
11
|
+
- **Orchestrator running** (see [Starting the Orchestrator](#starting-the-orchestrator))
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 1. Install wilfredwake
|
|
16
|
+
|
|
17
|
+
### Option A: Global Installation (Recommended)
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install -g wilfredwake
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Verify installation:
|
|
24
|
+
```bash
|
|
25
|
+
wilfredwake --version
|
|
26
|
+
wilfredwake --help
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Option B: Local Development
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Clone repository
|
|
33
|
+
git clone https://github.com/wilfred/wilfredwake.git
|
|
34
|
+
cd wilfredwake
|
|
35
|
+
|
|
36
|
+
# Install dependencies
|
|
37
|
+
npm install
|
|
38
|
+
|
|
39
|
+
# Link for local use
|
|
40
|
+
npm link
|
|
41
|
+
|
|
42
|
+
# Test
|
|
43
|
+
wilfredwake --version
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 2. Start the Orchestrator
|
|
49
|
+
|
|
50
|
+
The orchestrator is the always-on backend that manages services.
|
|
51
|
+
|
|
52
|
+
### Option A: Start Locally
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Terminal 1 - Start orchestrator
|
|
56
|
+
cd /home/wilfred/wilfredwake
|
|
57
|
+
npm run orchestrator
|
|
58
|
+
|
|
59
|
+
# Expected output:
|
|
60
|
+
# ╔════════════════════════════════╗
|
|
61
|
+
# ║ WILFREDWAKE ORCHESTRATOR ║
|
|
62
|
+
# ╚════════════════════════════════╝
|
|
63
|
+
# Loading service registry from: ./src/config/services.yaml
|
|
64
|
+
# ✓ Registry loaded: 6 services
|
|
65
|
+
# ✓ Orchestrator running on port 3000
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Option B: Production Deployment
|
|
69
|
+
|
|
70
|
+
Deploy the orchestrator to a server (AWS, Heroku, Railway, etc.):
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Build
|
|
74
|
+
npm install
|
|
75
|
+
npm run build
|
|
76
|
+
|
|
77
|
+
# Run
|
|
78
|
+
npm run orchestrator
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## 3. Initialize CLI Configuration
|
|
84
|
+
|
|
85
|
+
In a new terminal, configure your CLI:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
wilfredwake init
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Follow the prompts:
|
|
92
|
+
- **Orchestrator URL**: `http://localhost:3000` (or your server)
|
|
93
|
+
- **Environment**: `dev` (default)
|
|
94
|
+
- **API Token**: Optional
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## 4. Check Service Status
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Check all services
|
|
102
|
+
wilfredwake status
|
|
103
|
+
|
|
104
|
+
# Expected output:
|
|
105
|
+
# 📊 Services (DEV)
|
|
106
|
+
#
|
|
107
|
+
# SERVICE STATUS URL UPTIME
|
|
108
|
+
# auth READY https://auth-dev... 2h 30m
|
|
109
|
+
# database READY https://database-dev... 1h 15m
|
|
110
|
+
# payment-producer SLEEPING https://pay-prod... N/A
|
|
111
|
+
# payment-consumer READY https://pay-cons... 3h 00m
|
|
112
|
+
# api-gateway READY https://api-dev... 4h 30m
|
|
113
|
+
# notification SLEEPING https://notify-dev... N/A
|
|
114
|
+
#
|
|
115
|
+
# Summary
|
|
116
|
+
# ✓ Ready: 4 | ⚫ Sleeping: 2 | ⟳ Waking: 0 | ✗ Failed: 0
|
|
117
|
+
# Total: 6 services
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## 5. Wake Services
|
|
123
|
+
|
|
124
|
+
### Wake All Services
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
wilfredwake wake all
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Expected flow:
|
|
131
|
+
1. Auth wakes (no dependencies)
|
|
132
|
+
2. Database wakes (no dependencies)
|
|
133
|
+
3. Payment-producer wakes (depends on auth)
|
|
134
|
+
4. Payment-consumer wakes (depends on payment-producer and database)
|
|
135
|
+
5. API gateway wakes (depends on auth and database)
|
|
136
|
+
6. Notification wakes (depends on auth)
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## 6. Common Operations
|
|
141
|
+
|
|
142
|
+
### Wake a Specific Service
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# With dependencies
|
|
146
|
+
wilfredwake wake payment-consumer
|
|
147
|
+
# Will wake: auth → payment-producer → payment-consumer
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Wake a Service Group
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
# Payments group
|
|
154
|
+
wilfredwake wake payments
|
|
155
|
+
# Will wake: payment-producer → payment-consumer
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Health Check (No Waking)
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
wilfredwake health
|
|
162
|
+
|
|
163
|
+
# View specific service
|
|
164
|
+
wilfredwake health auth
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Different Environment
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
# Switch to staging
|
|
171
|
+
wilfredwake wake all -e staging
|
|
172
|
+
|
|
173
|
+
# Switch to production
|
|
174
|
+
wilfredwake wake all -e prod
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### JSON Output
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
wilfredwake status --format json
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Custom Timeout
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
# 10 minute timeout
|
|
187
|
+
wilfredwake wake all --timeout 600
|
|
188
|
+
|
|
189
|
+
# Don't wait (fire and forget)
|
|
190
|
+
wilfredwake wake all --no-wait
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## Configuration
|
|
196
|
+
|
|
197
|
+
Your configuration is stored in:
|
|
198
|
+
```bash
|
|
199
|
+
cat ~/.wilfredwake/config.json
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
To reconfigure:
|
|
203
|
+
```bash
|
|
204
|
+
wilfredwake init
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## Service Registry
|
|
210
|
+
|
|
211
|
+
Edit service definitions in:
|
|
212
|
+
```bash
|
|
213
|
+
# Local
|
|
214
|
+
nano src/config/services.yaml
|
|
215
|
+
|
|
216
|
+
# After edit, reload:
|
|
217
|
+
curl -X POST http://localhost:3000/api/reload
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
To add a new service, edit `services.yaml`:
|
|
221
|
+
|
|
222
|
+
```yaml
|
|
223
|
+
services:
|
|
224
|
+
dev:
|
|
225
|
+
my-service:
|
|
226
|
+
url: https://my-service-dev.onrender.com
|
|
227
|
+
health: /health
|
|
228
|
+
wake: /wake
|
|
229
|
+
dependsOn: [auth]
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Then reload and use immediately:
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
wilfredwake wake my-service
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## Troubleshooting
|
|
241
|
+
|
|
242
|
+
### "Could not connect to orchestrator"
|
|
243
|
+
|
|
244
|
+
1. **Check orchestrator is running:**
|
|
245
|
+
```bash
|
|
246
|
+
curl http://localhost:3000/health
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
2. **Check configuration:**
|
|
250
|
+
```bash
|
|
251
|
+
cat ~/.wilfredwake/config.json
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
3. **Reinitialize:**
|
|
255
|
+
```bash
|
|
256
|
+
wilfredwake init --orchestrator http://correct-url:3000
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Service times out
|
|
260
|
+
|
|
261
|
+
Increase timeout:
|
|
262
|
+
```bash
|
|
263
|
+
wilfredwake wake all --timeout 900 # 15 minutes
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Service shows as "sleeping" but not waking
|
|
267
|
+
|
|
268
|
+
Check service logs and ensure `/wake` endpoint is working:
|
|
269
|
+
```bash
|
|
270
|
+
curl -X POST https://service-url/wake
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## Development
|
|
276
|
+
|
|
277
|
+
### Start in Watch Mode
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
# Terminal 1 - Orchestrator with watch
|
|
281
|
+
npm run orchestrator:dev
|
|
282
|
+
|
|
283
|
+
# Terminal 2 - CLI with watch (if developing commands)
|
|
284
|
+
npm run dev
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Run Tests
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
npm test
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### Debug
|
|
294
|
+
|
|
295
|
+
Enable verbose logging:
|
|
296
|
+
```bash
|
|
297
|
+
# In ~/.wilfredwake/config.json
|
|
298
|
+
{
|
|
299
|
+
"preferences": {
|
|
300
|
+
"verbose": true
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
## Next Steps
|
|
308
|
+
|
|
309
|
+
1. **Read the full README** for detailed documentation
|
|
310
|
+
2. **Customize the service registry** for your services
|
|
311
|
+
3. **Deploy the orchestrator** to your infrastructure
|
|
312
|
+
4. **Share with your team** - Everyone uses the same orchestrator
|
|
313
|
+
5. **Integrate with CI/CD** - Automate service waking
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
## Getting Help
|
|
318
|
+
|
|
319
|
+
- **Help command:**
|
|
320
|
+
```bash
|
|
321
|
+
wilfredwake --help
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
- **Command-specific help:**
|
|
325
|
+
```bash
|
|
326
|
+
wilfredwake wake --help
|
|
327
|
+
wilfredwake status --help
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
- **Issues:**
|
|
331
|
+
https://github.com/wilfred/wilfredwake/issues
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
## Common Workflows
|
|
336
|
+
|
|
337
|
+
### Developer Starts Day
|
|
338
|
+
|
|
339
|
+
```bash
|
|
340
|
+
# Wake all services
|
|
341
|
+
wilfredwake wake all
|
|
342
|
+
|
|
343
|
+
# Check status
|
|
344
|
+
wilfredwake status
|
|
345
|
+
|
|
346
|
+
# Start development
|
|
347
|
+
# ... your IDE, your code ...
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### Testing Specific Service
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
# Wake only that service and dependencies
|
|
354
|
+
wilfredwake wake payment-consumer
|
|
355
|
+
|
|
356
|
+
# Health check
|
|
357
|
+
wilfredwake health payment-consumer
|
|
358
|
+
|
|
359
|
+
# Test
|
|
360
|
+
# ... run tests ...
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
### After Pull Request
|
|
364
|
+
|
|
365
|
+
```bash
|
|
366
|
+
# Pull latest changes (including service registry)
|
|
367
|
+
git pull
|
|
368
|
+
|
|
369
|
+
# Reload service registry
|
|
370
|
+
curl -X POST http://localhost:3000/api/reload
|
|
371
|
+
|
|
372
|
+
# Wake any new services
|
|
373
|
+
wilfredwake wake all
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
---
|
|
377
|
+
|
|
378
|
+
## Best Practices
|
|
379
|
+
|
|
380
|
+
✅ **Do:**
|
|
381
|
+
- Run orchestrator in a shared, always-on location
|
|
382
|
+
- Keep service registry updated with current services
|
|
383
|
+
- Use appropriate timeouts for your services
|
|
384
|
+
- Check health before reporting issues
|
|
385
|
+
|
|
386
|
+
❌ **Don't:**
|
|
387
|
+
- Run orchestrator on your laptop
|
|
388
|
+
- Hardcode service URLs in the CLI
|
|
389
|
+
- Ignore circular dependency errors
|
|
390
|
+
- Mix different service registries
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
**Ready to wake some services? Run:**
|
|
395
|
+
|
|
396
|
+
```bash
|
|
397
|
+
wilfredwake wake all
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
Happy developing! 🌅
|