Repository navigation
Expand file tree
/
Copy pathrun.command
More file actions
executable file
·56 lines (45 loc) · 1.48 KB
/
Copy pathrun.command
File metadata and controls
executable file
·56 lines (45 loc) · 1.48 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
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
pick_python() {
for candidate in python3.13 python3.12 python3.11 python3.10 python3; do
if command -v "$candidate" >/dev/null 2>&1; then
echo "$candidate"
return 0
fi
done
return 1
}
if ! PYTHON_BIN="$(pick_python)"; then
echo "Python is not installed. Install Python 3.10-3.13 first."
echo "https://www.python.org/downloads/"
exit 1
fi
PY_VERSION="$("$PYTHON_BIN" -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')"
case "$PY_VERSION" in
3.10|3.11|3.12|3.13) ;;
*)
echo "Unsupported Python version: $PY_VERSION"
echo "Please use Python 3.10, 3.11, 3.12, or 3.13."
exit 1
;;
esac
echo "Using $("$PYTHON_BIN" --version)"
if [ ! -d ".venv" ]; then
"$PYTHON_BIN" -m venv .venv
fi
# shellcheck disable=SC1091
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
# Best effort: raise soft nofile to hard limit so large sellers do not exhaust FDs.
HARD_LIMIT="$(ulimit -Hn 2>/dev/null || true)"
if [ -n "${HARD_LIMIT:-}" ] && [ "$HARD_LIMIT" != "unlimited" ]; then
ulimit -n "$HARD_LIMIT" 2>/dev/null || true
fi
APP_HOST="${APP_HOST:-127.0.0.1}"
APP_PORT="${APP_PORT:-5080}"
echo "Open file limit: $(ulimit -Sn 2>/dev/null || echo "unknown")"
echo "Starting app at http://${APP_HOST}:${APP_PORT}"
exec flask --app app run --host "$APP_HOST" --port "$APP_PORT"