Skip to content

morca ui: serve on several workers, and log requests (#539) - #540

Merged
winding-lines merged 2 commits into
mainfrom
ui-workers-539
Nov 18, 2026
Merged

winding-lines merged 2 commits into
mainfrom
ui-workers-539

Conversation

@winding-lines

@winding-lines winding-lines commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Closes #539.

  • MORCA_UI_WORKERS sets how many threads answer requests (default 1). The Hetzner stack's UI runs 4: morca-stack sets it, and the deploy tools go to 0.35.0. With several workers, the threads share one listening socket (flare's FLARE_REUSEPORT_WORKERS=0, unless that's set), so a new connection goes to a free thread instead of waiting behind a slow page. On prod, the UI's single thread queued requests for up to 66 s while Postgres stayed under 10 ms.
  • Each request except /healthz and the stylesheet is logged as one line: method, URL, status, ms, client, CF-Connecting-IP, User-Agent.
  • The default stays at 1 because a drain on several workers doesn't close their listening socket. New connections are still answered until the loop stops, and a UI restarted on the same port at once can't bind it. Each stack container has its own address, so the stack is unaffected. This is documented in docs/ui.md.
  • tests/ui_drain.sh adds a case on 2 workers: a request is answered while another waits on a lock, SIGTERM still lets the slow request finish, and the request is logged.

Tested locally (ouromo): test-ui-drain, test-ui-login, test-ui, tests/hetzner-version.sh ok.

🤖 Generated with Claude Code

https://claude.ai/code/session_017TycszSbyw92Efu4ZeCYL6

winding-lines and others added 2 commits November 17, 2026 18:20
MORCA_UI_WORKERS threads (default the cores up to 4) share one listening
socket, so a new connection goes to a free thread instead of queueing
behind a slow page. Each request but /healthz and the stylesheet is logged
as one line: method, URL, status, ms, client, CF-Connecting-IP, User-Agent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017TycszSbyw92Efu4ZeCYL6
A drain on several workers keeps the listening socket until the loop stops,
so a UI restarted at once on the same port couldn't bind it (ui_login.sh).
Each stack container has its own address, so its UI can run 4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017TycszSbyw92Efu4ZeCYL6
@winding-lines
winding-lines merged commit 194dc56 into main Nov 18, 2026
35 checks passed
@winding-lines
winding-lines deleted the ui-workers-539 branch November 18, 2026 02:46
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.

morca ui: serve on several workers, and log requests (prod UI queues for up to 66 s)

1 participant