-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
42 lines (31 loc) · 975 Bytes
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh
# Set PYTHONPATH to include /app/my_module
export PYTHONPATH=/app/src
# Function to run the Python script
run_python_script() {
python /app/src/pufo_twitter_bot/__main__.py -c 5 -s offenedaten --tweet
}
# Maximum number of attempts
max_attempts=5
# Counter for the attempts
attempts=0
# Loop until the script succeeds or the maximum number of attempts is reached
while true; do
attempts=$((attempts + 1))
echo "Attempt $attempts..."
# Run the Python script and capture its exit status
run_python_script
exit_status=$?
if [ $exit_status -eq 0 ]; then
echo "Script succeeded!"
exit 0
else
echo "Script failed with exit code $exit_status."
if [ $attempts -ge $max_attempts ]; then
echo "Maximum number of attempts reached. Exiting."
exit 1
fi
# Sleep for a while before the next attempt (adjust the sleep duration as needed)
sleep 5
fi
done