Mercurial
view hg-web/dev.sh @ 271:13d61401c57d
redirect Copilot cache to service state
Set XDG_CACHE_HOME from the configured inference state so the systemd service can extract Copilot outside its protected home directory.
Co-authored-by: Copilot <[email protected]>
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Fri, 07 Aug 2026 13:24:05 -0700 |
| parents | c5129452493e |
| children |
line wrap: on
line source
#!/usr/bin/env bash set -euo pipefail if [[ -n "${RUNFILES_DIR:-}" ]]; then source "$RUNFILES_DIR/bazel_tools/tools/bash/runfiles/runfiles.bash" elif [[ -n "${RUNFILES_MANIFEST_FILE:-}" ]]; then runfiles_library="$( grep -sm1 '^bazel_tools/tools/bash/runfiles/runfiles.bash ' \ "$RUNFILES_MANIFEST_FILE" | cut -d' ' -f2- )" source "$runfiles_library" elif [[ -d "$0.runfiles" ]]; then RUNFILES_DIR="$0.runfiles" export RUNFILES_DIR source "$RUNFILES_DIR/bazel_tools/tools/bash/runfiles/runfiles.bash" elif [[ -f "$0.runfiles_manifest" ]]; then RUNFILES_MANIFEST_FILE="$0.runfiles_manifest" export RUNFILES_MANIFEST_FILE runfiles_library="$( grep -sm1 '^bazel_tools/tools/bash/runfiles/runfiles.bash ' \ "$RUNFILES_MANIFEST_FILE" | cut -d' ' -f2- )" source "$runfiles_library" else echo "Bazel runfiles are unavailable." >&2 exit 1 fi workspace="${BUILD_WORKSPACE_DIRECTORY:-}" if [[ -z "$workspace" || ! -d "$workspace/.hg" ]]; then echo "Run this target from the Zenbu workspace." >&2 exit 1 fi server="$(rlocation _main/hg-web/hg_web_server)" hg_binary="$(rlocation _main/third_party/mercurial/runtime/bin/hg)" runfiles_workspace="$(dirname "$(dirname "$server")")" hg_pid="" server_pid="" cleanup() { trap - EXIT INT TERM for pid in "$server_pid" "$hg_pid"; do if [[ -n "$pid" ]] && kill -0 "$pid" 2>/dev/null; then kill "$pid" 2>/dev/null || true fi done for pid in "$server_pid" "$hg_pid"; do if [[ -n "$pid" ]]; then wait "$pid" 2>/dev/null || true fi done } trap cleanup EXIT trap 'exit 130' INT TERM HGRCPATH= "$hg_binary" \ --config "web.allow-push=" \ --config "web.deny-push=*" \ --repository "$workspace" serve \ --address 127.0.0.1 \ --port 4444 \ --accesslog - \ --errorlog - & hg_pid=$! ( cd "$runfiles_workspace" exec "$server" ) & server_pid=$! echo "hg-web: http://127.0.0.1:6970" echo "Mercurial wire endpoint: http://127.0.0.1:6970/repo" echo "Press Ctrl-C to stop both servers." set +e wait -n "$hg_pid" "$server_pid" status=$? set -e exit "$status"