blob: f6e0195e695d91d5aa36eae92a4c12d5e0aadc6f (
plain)
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
|
#!/bin/bash
# Script to update the KISSmo Perl repository and restart the application
# Navigate to the application directory. Exit if the directory is not found.
cd /app || { echo "$(date): Error: /app directory not found. Aborting update." >> /var/log/cron.log; exit 1; }
echo "$(date): Starting KISSmo Perl update..." >> /var/log/cron.log
# Pull the latest changes from the Git repository
git pull
if [ $? -ne 0 ]; then
echo "$(date): Git pull failed. Aborting update." >> /var/log/cron.log
exit 1
fi
echo "$(date): Git repository updated successfully." >> /var/log/cron.log
# Find the PID of the running KISSmo Perl process and kill it.
# We use 'pgrep -f' to match the full command line of the perl process.
PIDS=$(pgrep -f "perl paste.pl daemon -m production -l http://0.0.0.0:7878")
if [ -n "$PIDS" ]; then
echo "$(date): Found running KISSmo Perl processes: $PIDS. Killing them..." >> /var/log/cron.log
kill $PIDS
# Give the process some time to shut down gracefully
sleep 5
else
echo "$(date): No running KISSmo Perl processes found to kill." >> /var/log/cron.log
fi
# Start the application again in daemon mode
echo "$(date): Restarting KISSmo Perl application..." >> /var/log/cron.log
perl paste.pl daemon -m production -l http://0.0.0.0:7878
if [ $? -ne 0 ]; then
echo "$(date): Failed to restart KISSmo Perl application." >> /var/log/cron.log
exit 1
fi
echo "$(date): KISSmo Perl restarted successfully." >> /var/log/cron.log
|