-
Notifications
You must be signed in to change notification settings - Fork 0
/
render_webpage.sh
58 lines (53 loc) · 1.53 KB
/
render_webpage.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
49
50
51
52
53
54
55
56
57
58
#!/bin/sh
# run: "sh render_webpage.sh"
# run: "sh render_webpage.sh -f" for fast render
fast=false
web_server=true
echo_help() {
echo "HELP:"
echo "use -f for fast render mode"
echo "use -w to run without running test web server at the end"
echo "use -n start only the node server in the background"
echo "use -c to stop the node server running in the background"
}
node_server() {
cleanup
echo "\e[1;35mStarting node.js Server in background on 0.0.0.0 port 3000 (http://0.0.0.0:3000/) ... \e[0m"
node . > log_node.log &
}
cleanup() {
echo "\e[1;35mcleaning up open ports ... \e[0m"
fuser -k 3000/tcp
fuser -k 8000/tcp
}
while getopts 'fwnch?' flag; do
case "${flag}" in
f) fast=true ;;
w) web_server=false ;;
n) node_server
exit 0 ;;
c) cleanup
exit 0 ;;
*) echo_help
exit 1 ;;
esac
done
echo "\e[1;35mPreparing dir ... \e[0m"
rm -r -f $(pwd)/docs/
mkdir -p $(pwd)/docs/
cp $(pwd)/CNAME $(pwd)/docs/CNAME
node_server
cp $(pwd)/CNAME $(pwd)/docs/CNAME
echo "\e[1;35mStarting static render ... \e[0m"
if $fast ; then
echo "\e[1;32mUsing fast mode \e[0m"
/bin/python3 $(pwd)/save-webpage.py -c render-conf.json -f > log_save-webpage.log
else
echo "\e[1;32mThis might take a while, ingore the errors ... \e[0m"
/bin/python3 $(pwd)/save-webpage.py -c render-conf.json > log_save-webpage.log
fi
cleanup
if $web_server ; then
echo "\e[1;35mStarting HTTP.Server on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ... \e[0m"
/bin/python3 $(pwd)/webserver.py > log_webserver.log
fi