openclaw/scripts/gcp/logs.sh
Jonathan Nelson c063ce3e3a
GCP: add minimal container deployment with scripts
Co-Authored-By: Warp <agent@warp.dev>
2026-01-26 16:54:05 -05:00

30 lines
820 B
Bash
Executable File

#!/usr/bin/env bash
# View Clawdbot container logs on GCP VM
# Usage: ./logs.sh [VM_NAME] [--follow]
set -euo pipefail
VM_NAME="${1:-clawdbot-vm}"
FOLLOW="${2:-}"
PROJECT_ID=$(gcloud config get-value project 2>/dev/null)
REGION=$(gcloud config get-value compute/region 2>/dev/null)
ZONE="${REGION}-b"
if [[ -z "$PROJECT_ID" ]]; then
echo "Error: No GCP project configured. Run: gcloud config set project PROJECT_ID"
exit 1
fi
echo "Fetching logs from $VM_NAME..."
if [[ "$FOLLOW" == "--follow" ]] || [[ "$FOLLOW" == "-f" ]]; then
gcloud compute ssh "$VM_NAME" \
--zone="$ZONE" \
--tunnel-through-iap \
--command="sudo journalctl -u konlet-startup -f"
else
gcloud compute ssh "$VM_NAME" \
--zone="$ZONE" \
--tunnel-through-iap \
--command="sudo journalctl -u konlet-startup -n 100"
fi