summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/debug-execution34
1 files changed, 24 insertions, 10 deletions
diff --git a/scripts/debug-execution b/scripts/debug-execution
index 87540b7..b4873b9 100755
--- a/scripts/debug-execution
+++ b/scripts/debug-execution
@@ -1,13 +1,14 @@
#!/usr/bin/env bash
# debug-execution: Show details for a failed task execution from the production DB.
-# Usage: ./scripts/debug-execution <execution-id-or-prefix>
+# Usage: ./scripts/debug-execution [execution-id-or-prefix]
# Example: ./scripts/debug-execution c74c877f
+# If no ID is given, defaults to the most recent execution.
set -euo pipefail
DB="/site/doot.terst.org/data/claudomator.db"
DATA_DIR="/site/doot.terst.org/data"
-PREFIX="${1:?Usage: $0 <execution-id-or-prefix>}"
+PREFIX="${1:-}"
if [[ ! -f "$DB" ]]; then
echo "ERROR: DB not found at $DB" >&2
@@ -15,16 +16,29 @@ if [[ ! -f "$DB" ]]; then
fi
# Look up execution
-ROW=$(sqlite3 "$DB" "
- SELECT id, task_id, exit_code, status, stdout_path, stderr_path, error_msg
- FROM executions
- WHERE id LIKE '${PREFIX}%'
- ORDER BY start_time DESC
- LIMIT 1;
-")
+if [[ -z "$PREFIX" ]]; then
+ ROW=$(sqlite3 "$DB" "
+ SELECT id, task_id, exit_code, status, stdout_path, stderr_path, error_msg
+ FROM executions
+ ORDER BY start_time DESC
+ LIMIT 1;
+ ")
+else
+ ROW=$(sqlite3 "$DB" "
+ SELECT id, task_id, exit_code, status, stdout_path, stderr_path, error_msg
+ FROM executions
+ WHERE id LIKE '${PREFIX}%'
+ ORDER BY start_time DESC
+ LIMIT 1;
+ ")
+fi
if [[ -z "$ROW" ]]; then
- echo "ERROR: No execution found matching '${PREFIX}'" >&2
+ if [[ -z "$PREFIX" ]]; then
+ echo "ERROR: No executions found in DB" >&2
+ else
+ echo "ERROR: No execution found matching '${PREFIX}'" >&2
+ fi
exit 1
fi