The server’s database holds the live, editable copy of each script. A mirror keeps the whole document as a ScreenJSON file in a bucket too, for every system that would rather read a file: a CDN, a data lake, a backup, the screenjson-ui viewer.
1. Give the server a bucket
SCREENJSON_BLOB_DRIVER=s3
SCREENJSON_BLOB_REGION=us-east-1
SCREENJSON_BLOB_BUCKET=scripts
SCREENJSON_BLOB_ACCESS_KEY=…
SCREENJSON_BLOB_SECRET_KEY=…
For MinIO or another S3-compatible store, set SCREENJSON_BLOB_DRIVER=minio
and SCREENJSON_BLOB_ENDPOINT. For Azure, azure, with the account name and
key as the access and secret keys.
2. Turn on the mirror for a script
S=http://127.0.0.1:8080
curl -s -X PUT $S/documents/$DOC/settings -H "Authorization: Bearer $T" \
-d '{"mirror": {"enabled": true, "target": "s3://scripts/library/{doc}.json", "idle": "2m"}}'
From now on, two minutes after the last edit to the script, the server
rewrites s3://scripts/library/<id>.json with the whole document. {doc}
and {lang} in the target are filled in. The same setting is on the
script’s page in the web app.
3. Check it
curl -s -X POST $S/documents/$DOC/automation -H "Authorization: Bearer $T" \
-d '{"run": "mirror"}'
# {"ok": true, "result": {"target": "s3://scripts/library/3f64….json", "bytes": 7851, "seq": 3}}
GET …/automation shows when the mirror last ran and whether a run is
waiting for the script to go quiet. seq is the script’s change counter at
the time, so a reader can tell which version it has.
Every script in the library
Settings are per script. To mirror the whole library, loop over it:
curl -s "$S/documents?limit=1000" | jq -r '.items[].id' | while read -r id; do
curl -s -X PUT $S/documents/$id/settings -H "Authorization: Bearer $T" \
-d '{"mirror": {"enabled": true, "target": "s3://scripts/library/{doc}.json"}}' >/dev/null
done
One-off copies
To write a script to storage once, without a mirror:
curl -s -X POST $S/documents/$DOC/exports -d '{"target": "s3://scripts/snapshots/{doc}-{lang}.json"}'
PDF, Final Draft, Fade In and Fountain copies come from Greenlight: add
"exports": {"enabled": true, "formats": [{"format": "pdf"}]} to the same
settings to have them made after every burst of edits.
Next
- screenjson-server
- Script settings in the docs: Git, webhooks and exports.