perf: faster builds, leaner daemon, smoother install/run (0.9.20)
Reuse libcstcore.a for tests with -MMD incremental deps; idle-backoff the parliament seat loop; defer curl init and cache settings; add systemd helper. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -84,15 +84,20 @@ main() {
|
||||
|
||||
local jobs
|
||||
jobs="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4)"
|
||||
echo "==> build"
|
||||
if ((changed)); then
|
||||
echo "==> build (incremental, -j$jobs)"
|
||||
# Prefer incremental rebuilds. Set CST_AGENT_CLEAN=1 to force a clean tree.
|
||||
if [[ "${CST_AGENT_CLEAN:-0}" == "1" ]]; then
|
||||
run_make clean >/dev/null 2>&1 || true
|
||||
fi
|
||||
# `changed` is only used so re-exec after pull still builds; keep for clarity.
|
||||
: "${changed:=0}"
|
||||
if ! run_make -j"$jobs"; then
|
||||
deps_hint
|
||||
return 1
|
||||
fi
|
||||
run_make check >/dev/null 2>&1 || echo "warning: some tests failed (run 'make check')"
|
||||
if [[ "${CST_AGENT_SKIP_CHECK:-0}" != "1" ]]; then
|
||||
run_make -j"$jobs" check >/dev/null 2>&1 || echo "warning: some tests failed (run 'make check')"
|
||||
fi
|
||||
|
||||
echo "==> install to $prefix/bin"
|
||||
mkdir -p "$prefix/bin"
|
||||
@@ -103,6 +108,35 @@ export CST_AGENT_PREFIX="\${CST_AGENT_PREFIX:-$prefix}"
|
||||
exec bash "$dir/scripts/bootstrap_linux.sh" "$dir" "\$@"
|
||||
EOF
|
||||
chmod 0755 "$prefix/bin/cst-agent-update"
|
||||
cat >"$prefix/bin/cst-agent-service" <<EOF
|
||||
#!$(command -v bash)
|
||||
# Manage the parliament seat service (foreground under systemd, or --service).
|
||||
set -euo pipefail
|
||||
BIN="$prefix/bin/cst-agent"
|
||||
cmd="\${1:-status}"
|
||||
case "\$cmd" in
|
||||
status)
|
||||
"\$BIN" --version
|
||||
if command -v systemctl >/dev/null 2>&1 && systemctl --user is-active cst-agent-parliament.service >/dev/null 2>&1; then
|
||||
systemctl --user status cst-agent-parliament.service --no-pager
|
||||
else
|
||||
"\$BIN" --service-stop >/dev/null 2>&1 || true
|
||||
echo "parliament service: not managed by systemd --user (use --login / --service)"
|
||||
fi
|
||||
;;
|
||||
install-unit)
|
||||
make -C "$dir" install-service PREFIX="$prefix"
|
||||
;;
|
||||
start) systemctl --user start cst-agent-parliament.service ;;
|
||||
stop) systemctl --user stop cst-agent-parliament.service; "\$BIN" --service-stop || true ;;
|
||||
restart) systemctl --user restart cst-agent-parliament.service ;;
|
||||
*)
|
||||
echo "usage: cst-agent-service {status|install-unit|start|stop|restart}" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
EOF
|
||||
chmod 0755 "$prefix/bin/cst-agent-service"
|
||||
|
||||
echo
|
||||
echo "OK: $("$prefix/bin/cst-agent" --version)"
|
||||
@@ -110,7 +144,8 @@ EOF
|
||||
*":$prefix/bin:"*) ;;
|
||||
*) echo "Add to PATH: export PATH=\"$prefix/bin:\$PATH\"" ;;
|
||||
esac
|
||||
echo "Run 'cst-agent' inside a project directory; upgrade later with 'cst-agent-update'."
|
||||
echo "Run 'cst-agent' inside a project directory; upgrade with 'cst-agent-update'."
|
||||
echo "Parliament seat service helper: 'cst-agent-service status|install-unit'."
|
||||
echo "The first start asks for the provider and its API key and saves them."
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user