2022-01-25 20:07:21 +00:00
|
|
|
#!/bin/sh
|
2020-04-15 23:41:53 +00:00
|
|
|
# Usage:
|
2020-05-15 22:47:39 +00:00
|
|
|
# ./run # Runs the full web app
|
|
|
|
# ./run test # Runs the testing suite
|
2020-04-15 23:41:53 +00:00
|
|
|
|
2022-04-06 20:11:52 +00:00
|
|
|
set -e
|
2020-04-15 23:41:53 +00:00
|
|
|
|
2022-01-25 20:07:21 +00:00
|
|
|
SCRIPT_DIR="$(CDPATH= command cd -- "$(dirname -- "$0")" && pwd -P)"
|
2020-04-15 23:41:53 +00:00
|
|
|
|
|
|
|
# Set directory to serve static content from
|
2020-05-15 22:36:01 +00:00
|
|
|
SUBDIR="${1:-app}"
|
|
|
|
export APP_ROOT="$SCRIPT_DIR/$SUBDIR"
|
|
|
|
export STATIC_FOLDER="$APP_ROOT/static"
|
2020-04-15 23:41:53 +00:00
|
|
|
|
2021-11-01 22:20:22 +00:00
|
|
|
# Clear out build directory
|
|
|
|
rm -f "$SCRIPT_DIR"/app/static/build/*.js
|
|
|
|
rm -f "$SCRIPT_DIR"/app/static/build/*.css
|
|
|
|
|
2020-04-15 23:41:53 +00:00
|
|
|
# Check for regular vs test run
|
2022-01-25 20:07:21 +00:00
|
|
|
if [ "$SUBDIR" = "test" ]; then
|
2021-03-21 01:21:41 +00:00
|
|
|
# Set up static files for testing
|
|
|
|
rm -rf "$STATIC_FOLDER"
|
|
|
|
ln -s "$SCRIPT_DIR/app/static" "$STATIC_FOLDER"
|
2020-04-15 23:41:53 +00:00
|
|
|
pytest -sv
|
|
|
|
else
|
2021-03-21 01:21:41 +00:00
|
|
|
mkdir -p "$STATIC_FOLDER"
|
2022-04-06 20:11:52 +00:00
|
|
|
|
|
|
|
if [ ! -z "$UNIX_SOCKET" ]; then
|
|
|
|
python3 -um app \
|
|
|
|
--unix-socket "$UNIX_SOCKET"
|
|
|
|
else
|
|
|
|
python3 -um app \
|
|
|
|
--host "${ADDRESS:-0.0.0.0}" \
|
|
|
|
--port "${PORT:-"${EXPOSE_PORT:-5000}"}"
|
|
|
|
fi
|
2020-04-15 23:41:53 +00:00
|
|
|
fi
|