This repository was archived by the owner on Jan 30, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·45 lines (37 loc) · 1.36 KB
/
Copy pathstart.sh
File metadata and controls
executable file
·45 lines (37 loc) · 1.36 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
#!/usr/bin/env bash
set -Eeuo pipefail
REPO_DIR="/home/amti/Documents/Projects/Apps/Active/AIBot"
VENV_DIR="$REPO_DIR/.venv"
LOG_DIR="$REPO_DIR/logs"
LOG_FILE="$LOG_DIR/bot.log"
mkdir -p "$LOG_DIR"
cleanup() {
echo "[$(date --iso-8601=seconds)] stop signal received, shutting down" >> "$LOG_FILE"
}
trap cleanup SIGINT SIGTERM
cd "$REPO_DIR"
if [ ! -d "$VENV_DIR" ]; then
echo "Virtual environment not found at $VENV_DIR" | tee -a "$LOG_FILE"
exit 1
fi
if pgrep -f "$REPO_DIR/main.py" > /dev/null; then
echo "[$(date --iso-8601=seconds)] another bot process is already running; aborting" >> "$LOG_FILE"
exit 1
fi
source "$VENV_DIR/bin/activate"
# Allow the allocator to grow segments to mitigate fragmentation; keep both vars for older Torch builds.
export PYTORCH_ALLOC_CONF=expandable_segments:True
export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
while true; do
echo "[$(date --iso-8601=seconds)] starting bot" >> "$LOG_FILE"
python main.py >> "$LOG_FILE" 2>&1 || true
exit_code=$?
echo "[$(date --iso-8601=seconds)] bot exited with code $exit_code" >> "$LOG_FILE"
sleep 3
echo "[$(date --iso-8601=seconds)] restarting bot" >> "$LOG_FILE"
sleep 2
echo "[$(date --iso-8601=seconds)] restart cycle" >> "$LOG_FILE"
# Optional: limit restart attempts
# On repeated failures, add exponential backoff or exit
# For now, loop indefinitely.
done