Skip to content

feat(serve): bind port 0 and announce the port the system chose - #1062

Merged
yeongseon merged 1 commit into
mainfrom
feat/serve-port-zero
Oct 6, 2026
Merged

yeongseon merged 1 commit into
mainfrom
feat/serve-port-zero

Conversation

@Eomdahyeon

Copy link
Copy Markdown
Collaborator

무엇을

#1057 리뷰에서 "막지 않음"으로 남기신 것 — 스모크 테스트가 포트를 잡았다 놓고 다시 여는 사이의 경합 — 을 없앱니다.

  • serve --port 0: 운영체제가 포트를 고르고, serve 가 listening on http://<host>:<port> 를 한 줄 출력합니다. 다른 포트 값의 동작과 출력은 그대로입니다.
  • tests/unit/test_oidc_start_smoke.py: 미리 포트를 고르지 않고 --port 0 으로 띄운 뒤 그 줄에서 포트를 읽습니다. 60초 안에 그 줄이 없거나 프로세스가 먼저 끝나면 그때까지의 출력을 붙여 실패합니다.

알아 둘 것

  • --port 0 일 때 CLI 가 먼저 찍는 serving kpubdata-builder on http://…:0 줄은 그대로 :0 입니다. 실제 포트는 그 다음 줄에 나옵니다. 그 줄까지 바꾸려면 바인드를 CLI 쪽으로 옮겨야 해서 손대지 않았습니다.
  • 배포 설정(compose, Dockerfile)은 바꾸지 않았습니다. 기본 포트는 8000 그대로입니다.

검증

  • 스모크 5건을 3회 연속 통과 (각 약 5초)
  • ruff, mypy src 통과
  • 전체 단위 스위트는 로컬에서 돌리지 않았습니다. CI 에 맡깁니다.

Refs #992

🤖 Generated with Claude Code

The start-up smoke test picked a free port, released it and started
serve on it; another process could take it in between. serve now
accepts port 0 and prints the address it listens on, and the test reads
that.

Refs #992

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@yeongseon yeongseon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

diff 를 읽고 승인합니다. #1057 에서 "막지 않음" 으로 남긴 포트 경합이 이것으로 없어집니다.

  • port == 0 일 때만 한 줄을 더 찍으므로 다른 포트의 출력과 동작은 그대로입니다. 그 줄은 소켓이 바인드·listen 된 뒤에 찍히므로, 줄을 읽은 쪽이 바로 연결해도 serve_forever 전의 연결은 backlog 에서 기다립니다.
  • 테스트의 읽기 스레드가 포트를 찾은 뒤에도 stdout 을 계속 비우므로, serve 가 로그를 많이 써도 파이프가 차서 멈추지 않습니다.
  • 줄이 안 나오거나 프로세스가 먼저 끝나면 그때까지의 출력을 붙여 실패합니다.

serving … :0 줄이 그대로인 것은 본문대로 알아 둡니다.

@yeongseon
yeongseon merged commit 1b99a10 into main Oct 6, 2026
22 checks passed
@yeongseon
yeongseon deleted the feat/serve-port-zero branch October 7, 2026 22:23
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.

2 participants