chore: update .gitignore and untrack bot.pid, update bot.sh

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
IFM Telegram Bot
2026-02-23 11:22:11 +07:00
parent 33e24204fb
commit d1db387d1c
3 changed files with 17 additions and 2 deletions
+16 -1
View File
@@ -46,9 +46,24 @@ do_start() {
# Kill any stale tmux session
tmux kill-session -t "$TMUX_SESSION" 2>/dev/null
# Build env string from .env for tmux (since tmux doesn't inherit exports)
local ENV_EXPORTS=""
if [ -f "$BOT_DIR/.env" ]; then
while IFS='=' read -r key value; do
# Skip comments and empty lines
[[ "$key" =~ ^#.*$ || -z "$key" ]] && continue
# Remove surrounding quotes from value
value="${value%\"}"
value="${value#\"}"
value="${value%\'}"
value="${value#\'}"
ENV_EXPORTS+="export ${key}='${value}'; "
done < "$BOT_DIR/.env"
fi
# Start bot inside a detached tmux session (UTF-8 for Thai text)
tmux new-session -d -s "$TMUX_SESSION" \
"cd '$BOT_DIR' && LANG=C.UTF-8 LC_ALL=C.UTF-8 exec java -Dfile.encoding=UTF-8 -jar '$JAR_FILE' >> '$LOG_DIR/console.log' 2>&1"
"cd '$BOT_DIR' && ${ENV_EXPORTS}LANG=C.UTF-8 LC_ALL=C.UTF-8 exec java -Dfile.encoding=UTF-8 -jar '$JAR_FILE' >> '$LOG_DIR/console.log' 2>&1"
sleep 3