-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_server.sh
48 lines (39 loc) · 1.18 KB
/
start_server.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
43
44
45
46
47
48
set -o pipefail
LOGS_DIR="logs"
SCRAPER_LOGS="$LOGS_DIR/scraper"
SERVER_LOGS="$LOGS_DIR/server"
OUTPUT_BACKUP="output_backup"
# Ensure the log folders exist
if [ ! -d SCRAPER_LOGS ]; then
echo "Scraper log directory not found."
return 1
fi
if [ ! -d SERVER_LOGS ]; then
echo "Server log directory not found."
return 1
fi
# Keep a backup of the previous scrape
LOG_NAME=$(date +"%Y-%m-%d+%T")
$CURRENT_BACKUP="$OUTPUT_BACKUP/$LOG_NAME"
mkdir $CURRENT_BACKUP
mv "output/* $CURRENT_BACKUP"
# Start a scrape, outputting to console and to a log file
./lotus_scrape 2>&1 | tee "$SCRAPER_LOGS/$LOG_NAME"
# If the above fails, then something has gone wrong
# and it should be looked at by an admin!
# Keep the current server running until they do.
if [ $? -eq 1 ]; then
return;
fi
# Close the server, if open
pkill lotus_web
# Start the server, outputting to console and to a log file
LOG_NAME=$(date +"%Y-%m-%d+%T")
./lotus_web 2>&1 | tee "$SERVER_LOGS/$LOG_NAME"
# If the above fails, then something has gone wrong
# and it should be looked at by an admin!
# Since the server is the part that's not working,
# it obviously shouldn't be kept running.
if [ $? -eq 1 ]; then
return;
fi