diff --git a/README.md b/README.md index 4acc4d5..e152b81 100644 --- a/README.md +++ b/README.md @@ -183,6 +183,30 @@ docker run --rm -p 8642:8642 -p 9002-9202:9002-9202/udp \ -v $(pwd)/build/city/tiles:/world:ro -e SKYSIM_TILES=/world skysim ``` +`docker-entrypoint.sh` turns `SKYSIM_*` variables into flags: `SKYSIM_API_BIND`, +`SKYSIM_API_PORT`, `SKYSIM_VEHICLES`, `SKYSIM_TILES`, `SKYSIM_STREAM_RADIUS`, +`SKYSIM_STREAM_MAX`, `SKYSIM_DT`, `SKYSIM_TIME_MODE`, `SKYSIM_SPAWN_HOME`, and +`SKYSIM_EXTRA_ARGS` for anything not listed. + +**Set `SKYSIM_TIME_MODE=interactive` on a long-lived server.** The default is `strict`, +which is what determinism and CI replays need — a barrier every tick, and an abort when +a vehicle misses it. A server that vehicles join and leave wants the opposite, or one +lagging aircraft takes the fleet down with it. Match `SKYSIM_DT` to the scheduler rate +the vehicles are launched with, too: in lockstep, physics faster than the autopilot's +loop means most ticks miss their deadline. + +**`SKYSIM_CAMERA_FPS` is the camera switch.** Without it no frames are rendered and +the camera endpoints serve nothing, whatever else is set. With it, `SKYSIM_CAMERA_SIZE` +(default `256x144`), `SKYSIM_CAMERA_QUALITY`, `SKYSIM_CAMERA_THREADS`, +`SKYSIM_CAMERA_FOV`, `SKYSIM_CAMERA_PITCH` and `SKYSIM_CAMERA_RANGE` apply: + +```bash +docker run --rm -p 8642:8642 -p 9002-9202:9002-9202/udp \ + -v $(pwd)/build/city/tiles:/world:ro -e SKYSIM_TILES=/world \ + -e SKYSIM_CAMERA_FPS=10 -e SKYSIM_CAMERA_SIZE=256x144 skysim +# http://localhost:8642/instances/0/camera.mjpg +``` + --- ## Control plane (`--api-port`) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 6035a59..e52c0af 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -8,6 +8,16 @@ set -euo pipefail args=(--api-bind "${SKYSIM_API_BIND:-0.0.0.0}" --api-port "${SKYSIM_API_PORT:-8642}") +# One mapping, used by everything below: set the variable, get the flag; leave it +# unset and the binary's own default stands, so a default lives in one place +# rather than being restated here. +add_if_set() { # env-var-name flag + local value="${!1:-}" + if [[ -n "$value" ]]; then + args+=("$2" "$value") + fi +} + # Vehicles are normally spawned on demand over the control plane, so default to # starting with none rather than skysim's built-in default of one. args+=(--vehicles "${SKYSIM_VEHICLES:-0}") @@ -24,12 +34,31 @@ if [[ -n "${SKYSIM_TILES:-}" ]]; then fi fi -if [[ -n "${SKYSIM_DT:-}" ]]; then - args+=(--dt "${SKYSIM_DT}") -fi +add_if_set SKYSIM_DT --dt + +# Time mode, which a deployment could not set at all before. +# +# skysim defaults to strict because that is what determinism and CI replays need: +# a barrier every tick, and an abort when a vehicle misses it. A long-lived server +# wants the opposite — vehicles join and leave, some of them lag, and none of that +# should take the fleet down. Without this the only way to say so was +# SKYSIM_EXTRA_ARGS, so every deployment quietly ran strict. +add_if_set SKYSIM_TIME_MODE --time-mode + +add_if_set SKYSIM_SPAWN_HOME --spawn-home -if [[ -n "${SKYSIM_SPAWN_HOME:-}" ]]; then - args+=(--spawn-home "${SKYSIM_SPAWN_HOME}") +# Camera. SKYSIM_CAMERA_FPS is the switch — without --camera-fps the render +# service is never built and every other camera setting is inert, which is +# exactly how a deployment ends up serving a control plane with no pictures on +# it. The rest only apply once it is on. +if [[ -n "${SKYSIM_CAMERA_FPS:-}" ]]; then + args+=(--camera-fps "${SKYSIM_CAMERA_FPS}") + add_if_set SKYSIM_CAMERA_SIZE --camera-size + add_if_set SKYSIM_CAMERA_QUALITY --camera-quality + add_if_set SKYSIM_CAMERA_THREADS --camera-threads + add_if_set SKYSIM_CAMERA_FOV --camera-fov + add_if_set SKYSIM_CAMERA_PITCH --camera-pitch + add_if_set SKYSIM_CAMERA_RANGE --camera-range fi if [[ -n "${SKYSIM_EXTRA_ARGS:-}" ]]; then