# 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