- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 639
Enhance bin/dev kill to terminate processes on ports 3000 and 3001 #1846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance bin/dev kill to terminate processes on ports 3000 and 3001 #1846
Conversation
Previously, `bin/dev kill` only terminated processes by pattern matching (e.g., "rails", "puma", "webpack-dev-server"). This could miss processes that were holding ports 3000 or 3001 but didn't match the patterns. Now `bin/dev kill` also finds and terminates any process listening on ports 3000 and 3001 using `lsof -ti:PORT`, ensuring a clean restart even when unexpected processes are blocking the development ports. Changes: - Add kill_port_processes(ports) method to find and kill processes on specific ports - Add find_port_pids(port) helper that uses lsof to find PIDs listening on a port - Update kill_processes to call kill_port_processes([3000, 3001]) - Add comprehensive tests for port-killing functionality - Handle edge cases (lsof not found, permission denied) gracefully The port-killing is integrated as default behavior (no --force flag needed) since ports 3000/3001 are explicitly development ports and this matches the existing UX where kill doesn't ask for confirmation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
| Warning Rate limit exceeded@justin808 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 45 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the  We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
 ✨ Finishing touches
 🧪 Generate unit tests (beta)
 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment  | 
| Code Review - PR #1846✅ SummaryThis PR successfully enhances  🎯 Strengths1. Clean Implementation
 2. Excellent Test Coverage ✅All critical paths are tested: 
 3. Good Design Decisions
 4. Code Quality
 🔍 Minor Observations1. Error Handling Consistency (Minor)Location:  The  However, given this is a developer tool and silent failure is acceptable, the current approach is pragmatic. ✅ 2. Port Hardcoding (Design Question)Location:  Ports 3000 and 3001 are hardcoded in the  Not a blocker - the current approach aligns with React on Rails conventions. 🛡️ Security Review✅ No Security Concerns
 🚀 Performance Considerations✅ Good Performance Characteristics
 📊 Test Quality Assessment✅ Comprehensive Test CoverageThe test suite covers: 
 Well done! The tests use proper RSpec mocking patterns and align with existing test conventions. ✅ Final RecommendationAPPROVE - This PR is ready to merge. Summary
 Why This Is Good
 Pre-merge ChecklistAccording to CLAUDE.md: 
 🤖 Generated with Claude Code | 
Summary
Enhances
bin/dev killto also terminate any process listening on ports 3000 and 3001, ensuring a clean restart even when unexpected processes are blocking the development ports.Previously,
bin/dev killonly terminated processes by pattern matching (e.g., "rails", "puma", "webpack-dev-server"). This could miss processes that were holding ports 3000 or 3001 but didn't match the patterns.Key Improvements
lsof -ti:PORTlsofnot being available or permission issuesbin/dev killcommand (no new flags needed)Implementation Details
New Methods
kill_port_processes(ports)- Iterates through ports, finds PIDs, and terminates themfind_port_pids(port)- Useslsof -ti:PORTto find PIDs listening on a specific portUpdated Methods
kill_processes- Now callskill_port_processes([3000, 3001])in addition to pattern-based killingTests Added
lsofcommand not foundTest Plan
bin/dev killsuccessfully terminates processes on development portsFiles Changed
lib/react_on_rails/dev/server_manager.rb- Added port-killing functionalityspec/react_on_rails/dev/server_manager_spec.rb- Added comprehensive testsDesign Decision
Why default behavior instead of
--forceflag?🤖 Generated with Claude Code
This change is