Skip to content

feat: auto-register ports already in use (#73)#74

Merged
dapi merged 3 commits intomasterfrom
feat/auto-register-busyports
Feb 12, 2026
Merged

feat: auto-register ports already in use (#73)#74
dapi merged 3 commits intomasterfrom
feat/auto-register-busyports

Conversation

@dapi
Copy link
Owner

@dapi dapi commented Jan 21, 2026

Summary

  • When --lock <port> is used on a busy port, it now registers the port as "external" instead of failing
  • Added SOURCE column to --list output showing allocation source (free/lock/external)
  • Added --refresh command to clean up stale external port allocations
  • External allocations store process information (PID, user, process name)

Changes

  • allocations.go: Added Status, LockedAt, ExternalPID, ExternalUser, ExternalProcessName fields to AllocationInfo
  • allocations.go: Added SetExternalAllocation() and RefreshExternalAllocations() methods
  • logger.go: Added ALLOC_EXTERNAL and ALLOC_REFRESH logging events
  • main.go: Modified --lock to handle busy ports (same directory → locked, different directory → external)
  • main.go: Updated --list to show SOURCE column
  • main.go: Added new --refresh command
  • tests: Added unit tests for Store methods and updated integration tests
  • docs: Updated README.md, README.ru.md, CHANGELOG.md

Test plan

  • All existing tests pass
  • New unit tests for SetExternalAllocation and RefreshExternalAllocations
  • Updated TestLockPortInUseByAnotherProcess to expect success
  • Documentation updated in both English and Russian

🤖 Generated with Claude Code

dapi and others added 2 commits February 12, 2026 15:55
When --lock <PORT> is used on a busy port, it now registers the port
as "external" instead of failing. This prevents allocation conflicts
while keeping track of all busy ports.

- Add SOURCE column to --list (free/lock/external)
- Add --refresh command to clean up stale external ports
- Store external process info (PID, user, process name)
- Add new logging events: ALLOC_EXTERNAL, ALLOC_REFRESH

Co-Authored-By: Claude <noreply@anthropic.com>
- Use AllocExternal event in SetExternalAllocation() instead of AllocAdd/AllocUpdate
- Remove double-read of allocations: save externalProcessName inside WithStore
- Type Status field as AllocationStatus instead of string
- Rename StatusLocked to StatusNormal with accurate comment
- Set LockedAt timestamp in all SetLocked* methods (remove duplication from main.go)
- Panic on nil PortChecker in RefreshExternalAllocations (programming error)
- Add integration tests for --refresh and --list SOURCE column

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@dapi dapi force-pushed the feat/auto-register-busyports branch from 8d4dada to 76820a1 Compare February 12, 2026 13:15
- Add toAllocation() helper method to AllocationInfo
- Replace 6 duplicate allocation conversions with helper calls
- Add UnknownDirectoryFormat constant for "(unknown:%d)" pattern
- Remove duplicate LockedAt updates in main.go (already in SetLockedByPort)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@dapi dapi merged commit be63f19 into master Feb 12, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant