Skip to content

Commit

Permalink
Update ci.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Revulate authored Oct 17, 2024
1 parent 3d26043 commit 5887f1e
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ jobs:
apps: [{
name: "twitch-bot",
script: "bot.py",
interpreter: "/home/actionsrunner/revbot/venv/bin/python",
interpreter_args: "-u",
watch: false,
interpreter: process.platform === "win32" ? "python" : "/home/actionsrunner/revbot/venv/bin/python",
interpreter_args: "-u", // Use unbuffered mode
watch: true,
ignore_watch: [
"node_modules",
"logs",
Expand All @@ -160,16 +160,22 @@ jobs:
"*.db-journal",
".git"
],
instances: 1, // Ensure only one instance is started
exec_mode: "fork",
max_memory_restart: "1G",
env: {
NODE_ENV: "development",
PYTHONUNBUFFERED: "1",
PYTHONPATH: process.platform === "win32" ? "./env/Lib/site-packages" : "/home/actionsrunner/revbot/venv/lib/python3.11/site-packages"
},
env_production: {
NODE_ENV: "production",
PYTHONUNBUFFERED: "1",
PYTHONPATH: "/home/actionsrunner/revbot/venv/lib/python3.11/site-packages"
PYTHONPATH: process.platform === "win32" ? "./env/Lib/site-packages" : "/home/actionsrunner/revbot/venv/lib/python3.11/site-packages"
},
env_file: "/home/actionsrunner/revbot/.env",
error_file: "/home/actionsrunner/revbot/logs/err.log",
out_file: "/home/actionsrunner/revbot/logs/out.log",
env_file: process.platform === "win32" ? ".env" : "/home/actionsrunner/revbot/.env",
error_file: process.platform === "win32" ? "./logs/err.log" : "/home/actionsrunner/revbot/logs/err.log",
out_file: process.platform === "win32" ? "./logs/out.log" : "/home/actionsrunner/revbot/logs/out.log",
log_date_format: "YYYY-MM-DD HH:mm:ss Z",
restart_delay: 5000,
autorestart: true,
Expand All @@ -185,23 +191,29 @@ jobs:
}
EOF
echo "Starting/restarting bot with PM2..."
echo "Stopping any existing bot instances..."
pm2 stop twitch-bot || true
pm2 delete twitch-bot || true
echo "Starting bot with PM2..."
pm2 start ecosystem.config.js
echo "Saving PM2 process list..."
pm2 save
echo "Performing health check..."
sleep 30
if ! pm2 list | grep -q "online"; then
echo "Error: twitch-bot is not running after restart"
INSTANCE_COUNT=$(pm2 list | grep -c "twitch-bot")
if [ "$INSTANCE_COUNT" -ne 1 ]; then
echo "Error: Unexpected number of twitch-bot instances running: $INSTANCE_COUNT"
echo "PM2 status:"
pm2 list
echo "PM2 logs:"
pm2 logs --lines 50
echo "Rolling back to previous version..."
if [ -d "$BACKUP_DIR" ]; then
pm2 stop twitch-bot || true
pm2 delete twitch-bot || true
rm -rf $REVUBOT_DIR
mv $BACKUP_DIR $REVUBOT_DIR
cd $REVUBOT_DIR
Expand Down

0 comments on commit 5887f1e

Please sign in to comment.