hazine 0.1.0

Runs a DuckDB Quack server for DuckLake on localhost, reached through an SSH tunnel.
Documentation

hazine

hazine runs a DuckDB server that speaks the Quack protocol, for a DuckLake catalog, on localhost only. Clients reach it through an SSH tunnel.

It follows the pattern of DuckDB's own Quack deployment (duckdb-quack-infra): the DuckDB CLI runs an init file that ends in quack_serve, and keeps serving for as long as its stdin stays open. hazine replaces sleep infinity | duckdb -init init.sql with a supervisor that:

  • refuses any non-loopback listen address,
  • checks that the CLI is DuckDB 2.0 or later,
  • holds DuckDB's stdin open, and closes it to stop DuckDB cleanly on SIGTERM (killing it after --stop-timeout),
  • forwards DuckDB's output to its log (text or JSON), with QUACK_TOKEN redacted,
  • restarts DuckDB with backoff, and exits non-zero after --max-failures failed starts in a row, so systemd sees the failure.

nginx and TLS are not needed: the SSH tunnel provides authentication and encryption, and Quack checks a token on top.

Requirements

  • DuckDB CLI ≥ 2.0 with the quack extension: duckdb -c "INSTALL quack;"
  • Rust ≥ 1.85 to build

Server setup

cargo build --release
sudo install -m 0755 target/release/hazine /usr/local/bin/hazine
sudo install -d -o root -g hazine -m 0750 /etc/hazine
sudo install -m 0640 -g hazine dist/init.sql /etc/hazine/init.sql
sudo install -m 0640 -g hazine dist/hazine.env.example /etc/hazine/hazine.env
hazine token   # put the result in /etc/hazine/hazine.env as QUACK_TOKEN
sudo install -m 0644 dist/hazine.service /etc/systemd/system/hazine.service
sudo systemctl daemon-reload && sudo systemctl enable --now hazine

Edit /etc/hazine/init.sql to change the resource settings and the DuckLake attach. Keep the final quack_serve call: it listens on getenv('HAZINE_QUACK_ADDR'), and it selects only listen_uri, listen_url so that the token is not printed.

Connecting

ssh -N -L 1294:127.0.0.1:1294 <host>
LOAD quack;
FROM quack_query('quack:127.0.0.1:1294', 'SELECT 42',
                 token = '<QUACK_TOKEN>', disable_ssl = true);

Configuration

Precedence: flags > environment > defaults. See hazine serve --help.

Flag Environment Default
--duckdb HAZINE_DUCKDB duckdb (from PATH)
--init HAZINE_INIT /etc/hazine/init.sql
--database HAZINE_DATABASE in memory
--quack-addr HAZINE_QUACK_ADDR 127.0.0.1:1294
--ready-timeout HAZINE_READY_TIMEOUT 60 seconds
--stop-timeout HAZINE_STOP_TIMEOUT 30 seconds
--max-failures HAZINE_MAX_FAILURES 5
--log-format HAZINE_LOG_FORMAT text (or json)

The log level comes from RUST_LOG (default info).

License

MIT