myxce/src/frontend/apiserver
lei.chen 85a22271c1 Add X11 forwarding for interactive jobs (xcecli -I -X, ssh -X style)
Render -X jobs' windows on the user's own X server with zero client
install, mirroring the ssh -X experience: the job command starts with
DISPLAY pointed at a per-job TCP listener on the worker, and the user's
xcecli relays that listener's byte stream to their local X server.

- xcecli: new -X/--x11 flag (interactive=2 + exdata "x11":1). After
  submit it fetches the per-job MIT-MAGIC-COOKIE-1, registers it in the
  user's Xauthority, then bridges one xattach websocket to the local X
  server address parsed from $DISPLAY (unix socket or TCP). The cookie
  entry is removed when the session ends. Pre-flight checks report
  missing DISPLAY/xauth before submit.
- apiserver: GET /xce/v1/jobs/:id/xattach relays websocket binary frames
  to the worker's forwarding port (raw TCP, no ttyd). Close codes match
  the ttyd attach (4000 unreachable, 4001 ended). The job-finished event
  ends the relay. Teardown closes both hops as soon as either pump
  exits, so a client disconnect propagates instead of deadlocking in a
  blocking read.
- worker: XJOB jobs with exdata x11=1 skip VNC, listen on 6100-6199,
  generate a per-job xauth file (/tmp/job_<id>_xauth, worker-side since
  the worker has no session), export DISPLAY/XAUTHORITY to the command,
  and bridge the app connection (loopback) with the relay connection
  (non-loopback; roles classified by source address, not arrival order).
  A 60 s no-client watchdog reaps jobs nothing ever attached to; the
  v1 single-connection boundary refuses a second X connection loudly.

t1-verified per the plan matrix: window rendering (xclock/xeyes on
Xvfb), normal end -> DONE + xauth removed, no-client 60 s reap (137),
kill -> immediate teardown with no residue, -I/-I --browse regression,
daemon health, missing-DISPLAY error, second-connection refusal.
(--xjob VNC on t1 fails for lack of a vncserver binary; pre-existing.)

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-10-17 02:16:06 +00:00
..
backend Add X11 forwarding for interactive jobs (xcecli -I -X, ssh -X style) 2026-10-17 02:16:06 +00:00
cmd docs(apiserver): fix swag annotations and regenerate the swagger spec (bug-1966) 2026-10-10 10:37:52 +00:00
common style(frontend): gofmt the apiserver and xcecli sources 2026-10-02 09:33:16 +00:00
config merge: sync Rongsong's scheduler-framework (c5b172c7..3442a57d, 781 commits) 2026-10-14 05:17:03 +00:00
controllers Add X11 forwarding for interactive jobs (xcecli -I -X, ssh -X style) 2026-10-17 02:16:06 +00:00
docs fix(apiserver): reject submit options the job never gets; add exec_home (bug-1936) 2026-10-10 11:49:28 +00:00
middleware merge: sync Rongsong's scheduler-framework (c5b172c7..3442a57d, 781 commits) 2026-10-14 05:17:03 +00:00
models Add X11 forwarding for interactive jobs (xcecli -I -X, ssh -X style) 2026-10-17 02:16:06 +00:00
router Add X11 forwarding for interactive jobs (xcecli -I -X, ssh -X style) 2026-10-17 02:16:06 +00:00
services fix(apiserver): an accepted job is in the job store at once (bug-1894) 2026-09-30 04:23:10 +00:00
store merge: sync Rongsong's scheduler-framework (c5b172c7..3442a57d, 781 commits) 2026-10-14 05:17:03 +00:00
tools/encrypt fix(apiserver): bcrypt passwords and default-credential warnings in config-file auth (bug-1947) 2026-10-10 08:58:19 +00:00
utils fix(apiserver): validate, default and document job.terminate_interval (bug-1957) 2026-10-10 10:04:47 +00:00
vendor feat(interactive): attach TTY sessions through the apiserver websocket relay 2026-10-14 13:24:09 +00:00
go.mod feat(interactive): attach TTY sessions through the apiserver websocket relay 2026-10-14 13:24:09 +00:00
go.sum feat(interactive): attach TTY sessions through the apiserver websocket relay 2026-10-14 13:24:09 +00:00
meson.build feat(eliminate-frontend-makefile): task 1.1 - Meson backend CGO test target 2026-09-03 13:17:06 +00:00
README.md Merge Go frontend (apiserver + xcecli) into meson build 2026-04-14 11:23:18 +08:00

(1) run server command:

cd cmd go run main.go

(2) run server with different log level: cd cmd go run main.go -level=debug

level options: info/debug/warn/error/fatal