mirror of
https://github.com/nolen777/eagle0.git
synced 2026-07-28 21:55:42 +00:00
This reverts commit cccbbb9d37.
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Keeps the Bazel server alive for a given workspace directory.
|
||||
#
|
||||
# When run via launchd, this prevents GitHub Actions' orphan process cleanup
|
||||
# from being the only thing managing the Bazel server lifecycle. The server
|
||||
# stays warm between CI jobs, keeping the skyframe graph in memory and making
|
||||
# loading+analysis near-instant (~2s instead of ~20s).
|
||||
#
|
||||
# Usage: bazel-keepalive.sh <workspace-path>
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
WORKSPACE="${1:?Usage: bazel-keepalive.sh <workspace-path>}"
|
||||
|
||||
if [ ! -d "$WORKSPACE" ]; then
|
||||
echo "ERROR: Workspace not found: $WORKSPACE" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$WORKSPACE"
|
||||
|
||||
# 'bazel info server_pid' is the cheapest command that ensures the server
|
||||
# is running. If it's already up, this returns instantly.
|
||||
exec bazel info server_pid >/dev/null 2>&1
|
||||
@@ -1,103 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Installs a launchd agent that keeps the Bazel server alive on a CI runner.
|
||||
#
|
||||
# The Bazel server holds the loaded/analyzed build graph in memory (the
|
||||
# "skyframe graph"). GitHub Actions kills orphan processes after each job,
|
||||
# which kills the server and forces a cold reload on every CI run (~15-20s).
|
||||
#
|
||||
# This script installs a launchd agent that periodically pings the server,
|
||||
# keeping it alive between jobs. Since launchd owns the process (not the
|
||||
# GitHub Actions runner), the orphan cleanup won't touch it.
|
||||
#
|
||||
# Usage:
|
||||
# ./install-bazel-keepalive.sh <workspace-path>
|
||||
#
|
||||
# Example:
|
||||
# ./install-bazel-keepalive.sh ~/github/actions-runner-macos-build/_work/eagle0/eagle0
|
||||
#
|
||||
# To uninstall:
|
||||
# launchctl bootout gui/$(id -u) ~/Library/LaunchAgents/com.eagle0.bazel-keepalive.plist
|
||||
# rm ~/Library/LaunchAgents/com.eagle0.bazel-keepalive.plist
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
WORKSPACE="${1:?Usage: install-bazel-keepalive.sh <workspace-path>}"
|
||||
WORKSPACE=$(cd "$WORKSPACE" && pwd) # resolve to absolute path
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
KEEPALIVE_SCRIPT="${SCRIPT_DIR}/bazel-keepalive.sh"
|
||||
PLIST_PATH="${HOME}/Library/LaunchAgents/com.eagle0.bazel-keepalive.plist"
|
||||
LOG_DIR="${HOME}/Library/Logs/eagle0"
|
||||
BAZEL_PATH=$(which bazel)
|
||||
|
||||
if [ ! -x "$KEEPALIVE_SCRIPT" ]; then
|
||||
echo "ERROR: keepalive script not found at $KEEPALIVE_SCRIPT" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "$WORKSPACE" ]; then
|
||||
echo "ERROR: workspace not found at $WORKSPACE" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Unload existing agent if present
|
||||
if launchctl print "gui/$(id -u)/com.eagle0.bazel-keepalive" &>/dev/null; then
|
||||
echo "Unloading existing agent..."
|
||||
launchctl bootout "gui/$(id -u)" "$PLIST_PATH" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
mkdir -p "$LOG_DIR"
|
||||
mkdir -p "$(dirname "$PLIST_PATH")"
|
||||
|
||||
cat > "$PLIST_PATH" << EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
<string>com.eagle0.bazel-keepalive</string>
|
||||
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>${KEEPALIVE_SCRIPT}</string>
|
||||
<string>${WORKSPACE}</string>
|
||||
</array>
|
||||
|
||||
<key>EnvironmentVariables</key>
|
||||
<dict>
|
||||
<key>PATH</key>
|
||||
<string>$(dirname "$BAZEL_PATH"):/usr/local/bin:/usr/bin:/bin</string>
|
||||
</dict>
|
||||
|
||||
<!-- Run every 5 minutes to ensure the server stays alive -->
|
||||
<key>StartInterval</key>
|
||||
<integer>300</integer>
|
||||
|
||||
<!-- Also run at load (i.e., at login / system boot) -->
|
||||
<key>RunAtLoad</key>
|
||||
<true/>
|
||||
|
||||
<key>StandardOutPath</key>
|
||||
<string>${LOG_DIR}/bazel-keepalive.log</string>
|
||||
<key>StandardErrorPath</key>
|
||||
<string>${LOG_DIR}/bazel-keepalive.log</string>
|
||||
</dict>
|
||||
</plist>
|
||||
EOF
|
||||
|
||||
# Load the agent
|
||||
launchctl bootstrap "gui/$(id -u)" "$PLIST_PATH"
|
||||
|
||||
echo "Installed bazel-keepalive agent:"
|
||||
echo " Workspace: $WORKSPACE"
|
||||
echo " Plist: $PLIST_PATH"
|
||||
echo " Log: $LOG_DIR/bazel-keepalive.log"
|
||||
echo " Interval: every 5 minutes"
|
||||
echo ""
|
||||
echo "The Bazel server will now persist across GitHub Actions jobs."
|
||||
echo ""
|
||||
echo "To uninstall:"
|
||||
echo " launchctl bootout gui/\$(id -u) $PLIST_PATH"
|
||||
echo " rm $PLIST_PATH"
|
||||
Reference in New Issue
Block a user