mirror of
https://github.com/kellymichels/zscripts-token-savers
synced 2026-10-07 07:18:18 +00:00
Adds z_track_start/z_track_stop + z_record to zhelpers.sh and wires z_track_start into every command script. Each run now captures its own output volume (FIFO+tee, ANSI stripped), prints the '--- N lines / N chars / ~N tokens est. (Claude Code) ---' footer, and appends one JSONL row per top-level run in the same shape as the PowerShell tokens.jsonl. A nested-run guard keeps zrestart from double-counting its zkill/zstart children. Data dir precedence: $ZTOKENS_DATA, config ztokens.dataDir, sibling ../../ztokens/data, else ~/.ztokens/data. Docs + example config updated. Verified on WSL (isolated data dir): single run records correctly; nested zrestart produces one combined record, not three; est = round(chars/3.5).
39 lines
1.1 KiB
Bash
39 lines
1.1 KiB
Bash
#!/usr/bin/env bash
|
|
# Evomedia.net Token Savers — https://github.com/kellymichels/zscripts-token-savers
|
|
# Created by Kelly Michels · dev@evomedia.net
|
|
# Licensed under the MIT License. See LICENSE.
|
|
#
|
|
# zstop — stop docker compose stacks on the server without removing data or files.
|
|
#
|
|
# Usage:
|
|
# zstop <project> [<project> ...]
|
|
#
|
|
# Data volumes are preserved. Run zdeploy <project> to bring a stack back up.
|
|
|
|
set -uo pipefail
|
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/zhelpers.sh"
|
|
z_track_start "$@"
|
|
z_need_config
|
|
z_require ssh
|
|
|
|
if [ $# -eq 0 ]; then
|
|
printf '\n'; warn "Usage: zstop <project> [<project> ...]"
|
|
dim " Projects in zconfig.json: $(zproj_csv)"
|
|
exit 1
|
|
fi
|
|
|
|
for key in "$@"; do
|
|
zproj_require "$key"
|
|
label="$(zproj "$key" .label)"; [ -n "$label" ] || label="$key"
|
|
compose_dir="$(zremote_compose_dir "$key")"
|
|
|
|
printf '\n'; info "--- Stopping $label ---"
|
|
if zssh "cd $compose_dir && sudo docker compose down 2>&1 || true"; then
|
|
ok " $label stopped."
|
|
else
|
|
warn " WARNING: docker compose down returned non-zero for $label"
|
|
fi
|
|
done
|
|
|
|
printf '\n'; dim "Done. Data volumes are intact. Run zdeploy <project> to restart."
|