Commit 1969b2d
Add service dependency checking to bin/dev (#2098)
## Summary
This PR introduces a service dependency checking system that validates
required external services (like Redis, PostgreSQL, Elasticsearch) are
running before `bin/dev` starts the development server.
## Problem
Many applications depend on external services that must be running
before the dev server starts. Currently, there are two approaches:
1. **Include services in Procfile** (e.g., `redis: redis-server`) -
Works but clutters the Procfile
2. **Let Procfile fail** - Results in cryptic errors that confuse new
developers
Neither approach is ideal. The Procfile is meant for application
processes, not infrastructure services.
## Solution
A new `.dev-services.yml` configuration file that:
- Declaratively defines required services
- Checks if they're running before starting Procfile
- Provides helpful error messages with start commands
- Works cross-platform (macOS and Linux)
- Has zero impact if not used
## Key Features
✅ **Declarative configuration** - Simple YAML format
✅ **Self-documenting** - Includes `.dev-services.yml.example` template
✅ **Helpful errors** - Clear instructions on how to start missing
services
✅ **Cross-platform** - Works on macOS and Linux
✅ **Zero impact** - If no config exists, bin/dev works exactly as before
✅ **Test coverage** - 11 comprehensive tests, all passing
## Configuration Example
```yaml
services:
redis:
check_command: "redis-cli ping"
expected_output: "PONG"
start_command: "redis-server"
install_hint: "brew install redis (macOS) or apt-get install redis-server (Linux)"
description: "Redis (for caching and background jobs)"
postgresql:
check_command: "pg_isready"
expected_output: "accepting connections"
start_command: "pg_ctl -D /usr/local/var/postgres start"
description: "PostgreSQL database"
```
## User Experience
**When all services are running:**
```
🔍 Checking required services (.dev-services.yml)...
✓ redis - Redis (for caching and background jobs)
✓ postgresql - PostgreSQL database
✅ All services are running
[Procfile starts normally]
```
**When services are missing:**
```
🔍 Checking required services (.dev-services.yml)...
✗ redis - Redis (for caching and background jobs)
❌ Some services are not running
Please start these services before running bin/dev:
redis
Redis (for caching and background jobs)
To start:
redis-server
Not installed? brew install redis (macOS) or apt-get install redis-server (Linux)
💡 Tips:
• Start services manually, then run bin/dev again
• Or remove service from .dev-services.yml if not needed
• Or add service to Procfile.dev to start automatically
```
## Implementation Details
### New Files
- `lib/react_on_rails/dev/service_checker.rb` - Core service checking
logic
- `spec/react_on_rails/dev/service_checker_spec.rb` - Comprehensive test
suite
-
`lib/generators/react_on_rails/templates/base/base/.dev-services.yml.example`
- Template for new projects
- `spec/dummy/.dev-services.yml.example` - Example for dummy app
### Modified Files
- `lib/react_on_rails/dev/server_manager.rb` - Integrated service checks
before starting Procfile
- `lib/generators/react_on_rails/base_generator.rb` - Added
`.dev-services.yml.example` to generated files
### Service Checking Flow
1. Check if `.dev-services.yml` exists (if not, continue normally)
2. Load and parse YAML configuration
3. Run each service's `check_command`
4. Validate output against `expected_output` (if specified)
5. If all pass: continue to start Procfile
6. If any fail: display helpful errors and exit
## Benefits
🎯 **Self-documenting** - New developers see exactly what services are
needed
🎯 **Cleaner Procfiles** - Remove infrastructure services, keep only app
processes
🎯 **Better onboarding** - Clear instructions instead of cryptic failures
🎯 **Flexible** - Each app can define its own requirements
🎯 **Optional** - Zero impact on existing installations
## Test Plan
- [x] All 11 new tests passing
- [x] All existing dev module tests still passing (89 total)
- [x] RuboCop clean
- [x] Pre-commit hooks passing
- [x] Manual testing with dummy app
## Breaking Changes
None. This is purely additive. If `.dev-services.yml` doesn't exist,
`bin/dev` behaves exactly as before.
## Future Enhancements
Potential future improvements:
- Auto-start services with user confirmation
- Integration with Docker Compose
- Service health monitoring during development
- Template snippets for common services
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Added Service Dependency Checking for `bin/dev`: An optional
`.dev-services.yml` configuration file validates external services
(Redis, PostgreSQL, Elasticsearch, etc.) are running before the
development server starts. Provides clear error messages with startup
and installation guidance when services are missing. Fully backward
compatible—disabled by default.
<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 0263541 commit 1969b2d
File tree
10 files changed
+750
-5
lines changed- docs/building-features
- lib
- generators/react_on_rails
- templates/base/base
- react_on_rails/dev
- sig/react_on_rails/dev
- spec
- dummy
- react_on_rails/dev
10 files changed
+750
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
26 | 30 | | |
27 | 31 | | |
28 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
60 | 166 | | |
61 | 167 | | |
62 | 168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
Lines changed: 76 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
330 | 331 | | |
331 | 332 | | |
332 | 333 | | |
| 334 | + | |
333 | 335 | | |
334 | 336 | | |
335 | 337 | | |
| |||
340 | 342 | | |
341 | 343 | | |
342 | 344 | | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
343 | 360 | | |
344 | 361 | | |
| 362 | + | |
345 | 363 | | |
346 | 364 | | |
347 | 365 | | |
| |||
392 | 410 | | |
393 | 411 | | |
394 | 412 | | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
395 | 417 | | |
396 | 418 | | |
397 | 419 | | |
| |||
514 | 536 | | |
515 | 537 | | |
516 | 538 | | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
517 | 542 | | |
518 | 543 | | |
519 | 544 | | |
| |||
539 | 564 | | |
540 | 565 | | |
541 | 566 | | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
542 | 571 | | |
543 | 572 | | |
544 | 573 | | |
| |||
0 commit comments