Expand description
teamcraft local: a test installation on one computer, for trying
TeamCraft out without Docker or a database administrator. It runs a
private PostgreSQL cluster and the server, both only on 127.0.0.1, with
every file in one data directory:
<data dir>/postgres/ the cluster (initdb on the first start)
<data dir>/postgres.log PostgreSQL's log
<data dir>/db-password the generated database password (0600)
<data dir>/vault/ the file vaultThe PostgreSQL programs come from the release bundle (postgresql/bin
next to the executable, as the desktop app’s with local server
installers ship it), from --pg-bin, or from an installation on this
computer. The cluster gets its own free port and no Unix socket; it uses
scram-sha-256 with a random password, so other accounts on the computer
cannot connect. The desktop app starts this command for Try TeamCraft on
this computer (desktop/src/localserver.rs). Never for production:
one user’s laptop, no backups, no TLS.
Structs§
- Cluster
- The running PostgreSQL cluster of a local installation.
Constants§
- BUNDLED_
PG_ DIR - The directory the release bundles put the PostgreSQL programs in, next to
the
teamcraftexecutable (postgresql/bin/initdb, …). - DB_NAME
- DB_USER
- Database role and database of the local installation.
- DEFAULT_
PORT - HTTP port when none is given (the port of every other quick start).
- SIDECAR_
NAME - The name of this binary in the desktop downloads with local server
(
teamcraft-server[.exe]next to the app;desktop/src/localserver.rs).
Functions§
- default_
data_ dir - Where the data lives when no
--data-diris given: the per-user data directory of the operating system, so that the desktop app and the command line share one installation. - find_
pg_ bin - The first candidate that holds
initdb,pg_ctlandpostgres. - free_
port - A free TCP port on 127.0.0.1 (asked from the operating system).
- is_
pg_ bin - Whether
dirholds the programsteamcraft localruns. - local_
conf - The settings of one start, written to
teamcraft-local.confin the cluster: only 127.0.0.1, the given port, no Unix socket (nothing in /tmp, no socket directory that would need root). - local_
variables - The configuration variables of the local installation. They replace the
same variables (and their
_FILEforms) from the environment; seeoverlay_lookup. - overlay_
lookup - A lookup for
crate::config::Config::from_lookup: the local variables win, their_FILEforms and the database URLs are hidden, everything else (an assistant key, OIDC, …) comes fromenv. - pg_
bin_ candidates - The directories searched for the PostgreSQL programs, in order:
--pg-bin; the bundle next to the executable (and in the macOS app’sResources);PATH; the usual installation directories (Debian/Ubuntu/usr/lib/postgresql/<n>/bin, Homebrew, Postgres.app, the Windows installer), newest version first. - remove_
port_ file - Removes the port file again (after the cluster stopped).
- running_
instance - The port of another
teamcraft localthat still serves this data directory: its port file names a port whose/readyzanswers like TeamCraft. Starting a second one would stop its PostgreSQL (it looks left running), so the caller refuses instead. A port file left behind by a killed instance does not count. - stdin_
closed - Resolves when standard input reaches its end (or fails). The desktop app
starts
teamcraft local --exit-with-stdinwith a pipe it never writes to: when the app ends – also when it crashes or is killed – the pipe closes and the server and PostgreSQL shut down cleanly. A plain thread, not a blocking tokio task: the runtime would wait for it at shutdown. - write_
port_ file - Records the HTTP port of this instance in the data directory.