Files
LithosAnanke/demo/starshipos-demo.service
T
Claude 55613350c4 demo: CPUQuota 150%, as set on the server (#116) [skip ci]
Since #151 an idle guest halts (1% of a core at the prompt), so the cap no
longer has to hold back spinning sessions. Captain Bob set 1.5 cores for
all sessions together on the server (2026-11-08): one busy visitor a full
core, half a core always left to the wikis and Gitea. Confirmed on the
server with a live session idle for 3 minutes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GE3SDvQn5EoxdGufk84zz2
2026-11-08 02:09:52 +00:00

46 lines
2.1 KiB
Desktop File

# starshipos-demo.service -- the public demo's web terminal (issue #114): ttyd on localhost, one
# throwaway StarshipOS machine per browser connection (start-session.sh). Apache in front
# (apache-demo.conf) does TLS and the websocket.
#
# Install: the repository's demo/ at /opt/starshipos-demo/demo, the saved machine (make-snapshot.sh)
# in /var/lib/starshipos-demo, a user starshipos-demo; then systemctl enable --now starshipos-demo.
[Unit]
Description=StarshipOS public demo terminal (ttyd)
After=network.target
[Service]
User=starshipos-demo
Group=starshipos-demo
Environment=DEMO_STATE=/var/lib/starshipos-demo
Environment=DEMO_SESSION_LIMIT=1800
Environment=DEMO_MAX_GUESTS=2
# the guests' slot locks (start-session.sh): /run/starshipos-demo, made for this user, gone at stop
RuntimeDirectory=starshipos-demo
# --max-clients: the guests and a few more, so a visitor over the limit reaches the busy message
# instead of a refused connection; still a cap on open connections
# each guest a QEMU of 384 MiB and most of a core (demo/qemu-args.sh; #116)
ExecStart=/usr/bin/ttyd --port 7681 --interface lo --writable --max-clients 6 \
--client-option titleFixed=StarshipOS --client-option disableLeaveAlert=true \
/opt/starshipos-demo/demo/start-session.sh
Restart=on-failure
# Each session is already a sandboxed QEMU with no network; this fences ttyd and its children too.
NoNewPrivileges=yes
ProtectSystem=strict
ProtectHome=yes
PrivateTmp=yes
PrivateDevices=yes
ReadOnlyPaths=/var/lib/starshipos-demo
# Sized for this server (3.8 GiB, two cores; both wikis, Gitea, Nexus, CI). Since #151 an idle guest
# halts (1% of a core at the prompt, was 100%), so a session costs CPU only while its visitor runs
# something. All sessions together get 1.5 cores at the lowest priority (Captain Bob, 2026-11-08):
# one busy visitor a full core, two busy at once three-quarters each, and half a core always left
# to the wikis and Gitea. 1 GiB holds two sessions (~150 MB resident each) with room. Raise both
# with the server (8 GB: MemoryMax=2G, CPUQuota=200% or more).
MemoryMax=1G
CPUQuota=150%
Nice=19
TasksMax=200
[Install]
WantedBy=multi-user.target