-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint-gateway.sh
More file actions
28 lines (22 loc) · 898 Bytes
/
Copy pathentrypoint-gateway.sh
File metadata and controls
28 lines (22 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
set -e
mkdir -p /var/lib/claude-code-dispatch
# Start ttyd. -H makes it read the Remote-User header Authelia/Traefik
# already attach to authenticated requests and expose it as $TTYD_USER to
# whatever it spawns -- here, ttyd-dispatch, which routes the connection to
# that person's own worker container (creating one on first login).
ttyd -W -w / -p 7681 -I /usr/local/share/ttyd/index.html -H Remote-User /usr/local/bin/ttyd-dispatch &
ttyd_pid=$!
# Stop worker containers nobody has used in a while. See reap-idle-users.
/usr/local/bin/reap-idle-users &
reaper_pid=$!
shutdown() {
kill "$reaper_pid" 2>/dev/null || true
kill -TERM "$ttyd_pid" 2>/dev/null || true
wait "$ttyd_pid" 2>/dev/null || true
exit 0
}
trap shutdown TERM INT
echo "Claude Code gateway started."
echo " ttyd: port 7681 (routes each authenticated user to their own worker container)"
wait