- Added a dedicated
release_port_8765()function that specifically targets processes using port 8765 - Implemented fallback mechanisms using different command-line tools (lsof, ss) to ensure port detection works in various environments
- Added a wait period after port cleanup to ensure socket TIME_WAIT states are properly handled
- Updated the
find_available_portfunction to wait for the preferred port (8765) instead of incrementing to the next port - This ensures consistent port usage, which is essential for stable application URLs
- The server now properly respects the PORT environment variable, allowing consistent port specification
- Verified that the server consistently starts on port 8765 after the changes
- Confirmed proper cleanup of processes using port 8765 when shutting down the server
- Server responds properly on port 8765 as expected
- Consistent URL for users (always http://localhost:8765)
- More reliable server startup sequence
- Easier integration with external tools and tests
- Elimination of port conflicts between restarts
- Continue monitoring server stability during regular operation
- Conduct thorough user testing with the stable port
- Update documentation to reference the stable port consistently