-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·58 lines (50 loc) · 1.12 KB
/
run.sh
File metadata and controls
executable file
·58 lines (50 loc) · 1.12 KB
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/bash
#
# run locally for dev
#
set -o errexit
set -o pipefail
set -o nounset
echo "INFO: Starting dev server at $(date -u +%Y-%m-%dT%H:%M:%SZ)"
#
# load an .env file if it exists
#
ENV_FILE="${1:-./.env}"
if [ -f "${ENV_FILE}" ]; then
echo "INFO: loading '${ENV_FILE}'"
export $(cat "${ENV_FILE}")
fi
OUTPUT_DIR=${OUTPUT_DIR:-./output}
if [ ! -d "${OUTPUT_DIR}" ]; then
echo "INFO: output directory ${OUTPUT_DIR} does not exist. Run mediatitles.sh a few times first!"
exit 1
fi
BUILD_DIR=${BUILD_DIR:-./build}
if [ ! -d "${BUILD_DIR}" ]; then
echo "INFO: creating build directory ${BUILD_DIR}"
mkdir -p "${BUILD_DIR}"
fi
#
# make the index
#
echo "INFO: building index"
tar cvzf ${BUILD_DIR}/sourceData.tgz \
${OUTPUT_DIR}/*sourceData.json
#
# friendly exit message
#
function cleanup()
{
echo "INFO: Shutting down dev server at $(date -u +%Y-%m-%dT%H:%M:%SZ)"
exit 0
}
trap cleanup EXIT
#
# serve it
#
BIND=${BIND:-127.0.0.1}
PORT=${PORT:-4001}
echo "INFO: serving on ${BIND}:${PORT}. Use Ctrl-C to exit"
python3 -m http.server ${PORT} \
--bind "${BIND}" \
--directory "${BUILD_DIR}"