@@ -22,43 +22,30 @@ jobs:
22
22
needs : [deploy-via-sftp]
23
23
runs-on : ubuntu-latest
24
24
steps :
25
- - name : Debug and Restart Bot via SSH
25
+ - name : Restart Bot via SSH
26
26
uses : appleboy/ssh-action@v0.1.10
27
27
with :
28
28
host : ${{ secrets.SERVER_IP }}
29
29
username : root
30
30
key : ${{ secrets.SSH_PRIVATE_KEY }}
31
31
script : |
32
- echo "Step 1: Changing to /home/antbot/"
32
+ echo "Changing to /home/antbot/"
33
33
cd /home/antbot/
34
34
35
- echo "Step 2: Activating virtual environment"
35
+ echo "Activating virtual environment"
36
36
source .venv/bin/activate
37
37
38
- echo "Step 3: Checking Python version"
39
- python --version
40
-
41
- echo "Step 4: Checking for existing bot process"
42
- ps aux | grep 'python main.py' | grep -v grep || echo "No existing bot process found"
43
-
44
- echo "Step 5: Attempting to start bot"
45
- python main.py &
46
- echo $! > bot.pid
47
- echo "Bot start attempted, PID saved to bot.pid"
48
-
49
- echo "Step 6: Waiting for 5 seconds"
50
- sleep 5
51
-
52
- echo "Step 7: Checking if bot process is still running"
53
- if ps -p $(cat bot.pid); then
54
- echo "Bot is running with PID $(cat bot.pid)"
38
+ echo "Checking for existing bot process"
39
+ if pgrep -f 'python main.py'; then
40
+ echo "Stopping existing bot process"
41
+ pkill -f 'python main.py'
55
42
else
56
- echo "Bot is not running. Check logs for errors. "
43
+ echo "No existing bot process found "
57
44
fi
58
45
59
- echo "Step 8: Checking bot log (last 20 lines) "
60
- tail -n 20 bot.log || echo "Failed to read bot.log"
46
+ echo "Starting bot"
47
+ python main.py &
61
48
62
- echo "Step 9: Checking for any Python errors in syslog "
63
- grep python /var/log/syslog | tail -n 20 || echo "No recent Python errors in syslog"
64
- script_stop : true
49
+ echo "Workflow completed "
50
+ script_stop : true
51
+ timeout : 60s
0 commit comments