-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_echo.sh
More file actions
executable file
·90 lines (72 loc) · 2.38 KB
/
run_echo.sh
File metadata and controls
executable file
·90 lines (72 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env bash
set -e
VENV_DIR="vEcho"
LOG_DIR="logs"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# ---------------------------------------------------
# LOAD .env INTO SHELL ENVIRONMENT
# ---------------------------------------------------
if [ -f .env ]; then
set -a
. ./.env
set +a
fi
mkdir -p "$LOG_DIR"
IMPORTANT_LOG="$LOG_DIR/important.log"
LLM_LOG="$LOG_DIR/llm.log"
OTHER_LOG="$LOG_DIR/other.log"
TRACE_LOG="$LOG_DIR/trace.log"
TOOLS_LOG="$LOG_DIR/tools.log"
SHOW_EXTRA_WINDOWS="${SHOW_EXTRA_WINDOWS:-true}"
# Array to store PIDs of extra log windows
EXTRA_PIDS=()
cleanup_extra_windows() {
echo "🧹 Closing extra log windows..."
for pid in "${EXTRA_PIDS[@]}"; do
if kill -0 "$pid" 2>/dev/null; then
kill "$pid" 2>/dev/null || true
fi
done
}
# Trigger window cleanup
trap cleanup_extra_windows EXIT INT TERM
start_tail_for() {
local title="$1"
local file="$2"
if command -v gnome-terminal >/dev/null 2>&1; then
gnome-terminal -- bash -c "echo '$title'; echo 'Tailing $file'; tail -f \"$file\"; exec bash" &
EXTRA_PIDS+=($!)
elif command -v konsole >/dev/null 2>&1; then
konsole -e bash -c "echo '$title'; echo 'Tailing $file'; tail -f \"$file\"; exec bash" &
EXTRA_PIDS+=($!)
elif command -v x-terminal-emulator >/dev/null 2>&1; then
x-terminal-emulator -e bash -c "echo '$title'; echo 'Tailing $file'; tail -f \"$file\"; exec bash" &
EXTRA_PIDS+=($!)
else
echo "⚠️ Could not auto-open a terminal for '$title'. Run manually:"
echo " tail -f $file"
fi
}
# ---------------------------------------------------
# SHOW EXTRA WINDOWS
# ---------------------------------------------------
if [ "$SHOW_EXTRA_WINDOWS" = "true" ]; then
start_tail_for "IMPORTANT LOG (INFO+)" "$IMPORTANT_LOG"
start_tail_for "LLM LOG (requests/responses)" "$LLM_LOG"
start_tail_for "OTHER LOG (DEBUG+ app/tool)" "$OTHER_LOG"
start_tail_for "TRACE LOG (actions/flow)" "$TRACE_LOG"
start_tail_for "TOOLS LOG (toolkit/tool calls)" "$TOOLS_LOG"
else
echo "Extra windows disabled. Logs only saved to file."
fi
# ---------------------------------------------------
# CHECK VIRTUAL ENVIRONMENT
# ---------------------------------------------------
if [ ! -d "$VENV_DIR" ]; then
echo "❌ Virtualenv '$VENV_DIR' not found."
exit 1
fi
source "$VENV_DIR/bin/activate"
echo "🚀 Starting Echo..."
python ./Echo.py