mirror of
https://github.com/Dasemu/skipredictor.git
synced 2026-11-27 07:46:22 +00:00
chore(start): load env before bot launch
This commit is contained in:
1 parent
04eb0fde61
commit
a6bfc69894
1 file changed
+17
-3
@@ -15,6 +15,7 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|||||||
VENV="$SCRIPT_DIR/.venv"
|
VENV="$SCRIPT_DIR/.venv"
|
||||||
PYTHON="$VENV/bin/python"
|
PYTHON="$VENV/bin/python"
|
||||||
DATA_DIR="$SCRIPT_DIR/data"
|
DATA_DIR="$SCRIPT_DIR/data"
|
||||||
|
ENV_FILE="$SCRIPT_DIR/.env"
|
||||||
|
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
# Colors
|
# Colors
|
||||||
@@ -61,6 +62,17 @@ for arg in "$@"; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------
|
||||||
|
# 3.5 Load environment from .env when present
|
||||||
|
# ---------------------------------------------------------------
|
||||||
|
if [ -f "$ENV_FILE" ]; then
|
||||||
|
info "Loading environment from $ENV_FILE"
|
||||||
|
set -a
|
||||||
|
# shellcheck disable=SC1090
|
||||||
|
. "$ENV_FILE"
|
||||||
|
set +a
|
||||||
|
fi
|
||||||
|
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
# 4. Install cron job
|
# 4. Install cron job
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
@@ -95,14 +107,16 @@ if [ "$DO_BOT" = true ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Kill existing bot process if running
|
# Kill existing bot process if running
|
||||||
if pgrep -f "telegram_bot.py" > /dev/null 2>&1; then
|
if pgrep -f "bot/telegram_bot.py|bot\\.telegram_bot" > /dev/null 2>&1; then
|
||||||
warn "Killing existing bot process..."
|
warn "Killing existing bot process..."
|
||||||
pkill -f "telegram_bot.py" || true
|
pkill -f "bot/telegram_bot.py|bot\\.telegram_bot" || true
|
||||||
sleep 1
|
sleep 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
info "Starting Telegram bot..."
|
info "Starting Telegram bot..."
|
||||||
nohup "$PYTHON" "$SCRIPT_DIR/bot/telegram_bot.py" >> "$DATA_DIR/bot.log" 2>&1 &
|
: > "$DATA_DIR/bot.log"
|
||||||
|
nohup env PYTHONPATH="$SCRIPT_DIR" "$PYTHON" -m bot.telegram_bot \
|
||||||
|
</dev/null >> "$DATA_DIR/bot.log" 2>&1 &
|
||||||
BOT_PID=$!
|
BOT_PID=$!
|
||||||
info "Bot started (PID: $BOT_PID). Logs: $DATA_DIR/bot.log"
|
info "Bot started (PID: $BOT_PID). Logs: $DATA_DIR/bot.log"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in new issue
Block a user