diff --git a/.gitignore b/.gitignore index 5042d53..1549f8d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ target/ *.class *.jar *.log +*.pid .env data/ downloads/ diff --git a/bot.pid b/bot.pid deleted file mode 100644 index 5ee7533..0000000 --- a/bot.pid +++ /dev/null @@ -1 +0,0 @@ -3367690 diff --git a/bot.sh b/bot.sh index 06ec6a3..0633849 100755 --- a/bot.sh +++ b/bot.sh @@ -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