Command line / serve

serve

tinystore serve shares a store with programs on this machine and, with --listen, on others. It is the same program an SDK starts as a sidecar or a private child; only its listeners differ. It runs until Ctrl+C or tinystore stop.

sh
tinystore serve ./data
tinystore serve ./data --listen tls://0.0.0.0:7443 --tls-cert cert.pem --tls-key key.pem --tokens tokens.txt
tinystore stop ./data

Local

Without flags, programs on this machine find the server through <dir>/server/SERVE: a Unix socket, or a named pipe on Windows, and the secret of a proof. On every platform only the user the server runs as can read SERVE or connect, whoever else may read the store's directory. No token is needed: their permission is the file system's. If another user created <dir>/server/ first, serve refuses to start and names the folder: remove it and start again.

FlagDoes
--stdioone client on stdin and stdout, for a program that starts the server itself
--idle <span>stop once no client has been connected this long; never by default

An SDK's sidecar is serve with --idle 30s, and its private child is serve --stdio.

Remote

sh
tinystore token new admin >> tokens.txt
tinystore token new data >> tokens.txt
tinystore token new read >> tokens.txt
tinystore serve ./data --listen tls://0.0.0.0:7443 --tls-cert cert.pem --tls-key key.pem --tokens tokens.txt
FlagDoes
--listen tls://<host>:<port>serve other machines over TLS
--tls-cert <pem>the certificate chain it answers with
--tls-key <pem>its private key
--tokens <file>who may connect: a token a line
--max-connections <count>the remote clients it serves at once; as many as come by default

token new prints a capability and a random token:

read fx-o4leY8IHwDw-A-Yr-QwtChi8vDIoF94CANd9XSlk
CapabilityMay
adminanything, backups included
dataread and write the store
readonly read what the store holds, making nothing: SQL on a reader, no migrations, no publishes

--listen tls:// refuses to start without a certificate, a key and a tokens file. --listen tcp:// sends tokens in the clear, for a private network its operator trusts. The same server still serves this machine's programs through its local socket.

--max-connections 256 serves 256 remote connections at once. The next one is read up to its HELLO, its token checked, and answered GOAWAY with limit instead of a WELCOME (contract WIRE-12). Its client fails limit, naming the bound; an SDK whose connection was lost tries again later, as it does after any GOAWAY. A connection that leaves gives its place back. This machine's programs, on the local socket, are not counted. Without the flag there is no bound, as before, so that a server that took a client yesterday takes it today.

LimitError: this server takes 256 connections at most, and holds 256: try again later

The store

FlagDoes
--memory <size>what the engines may hold at once, 512MiB; 1 GiB with --listen
--durability full|oshow far a commit goes before it returns
--keep-free <size>the disk the store keeps free; 1 GiB by default
--encryption-key-file <file>the store's key, kept apart from its data
--older-encryption-key <file>an older key, which opens what it sealed; again for more
--self-metricsmeasure the store into its own metrics
--no-system-metricswith --self-metrics, leave out the machine
--max-series <count>the metrics series the store holds at most; 100,000 by default
--directory <name=path>a folder this server lists and reads as a directory; again for more

A client with a token names no path of the server's machine: it opens a directory by its name alone, and reaches only the folders --directory gave (Directories).

Output

On a terminal the server prints a banner and a line per event; anywhere else, in a container or a pipe, each line is a JSON object on stderr, ready for a log collector.

FlagDoes
--log-file <file>JSON lines to a file as well
--quietthe banner, warnings and errors only

LOG_LEVEL sets the least level that the server logs, info unless set. LOG_CONSOLE_LEVEL sets the least level on stderr alone, and wins over --quiet. For example, LOG_CONSOLE_LEVEL=error with --log-file shows only errors on stderr and keeps every line from info in the file.

In a container

sh
docker run -v /srv/chat:/data -p 7443:7443 ghcr.io/tinyshed/tinystore:0.13 \
  serve /data --listen tls://0.0.0.0:7443 --tls-cert /data/cert.pem --tls-key /data/key.pem --tokens /data/tokens.txt

Nodes

--node-listen, --from and --node-config each make the store a node: see Nodes.

Stop

sh
tinystore stop ./data

The clients are told to leave and the streams running finish, then the store closes. With no server it says so and exits 1.

See also

Edit this page on GitHub Updated 27 November 2026

esc
↑↓ navigate ↵ open ⇥ filter 0 results