SuhasGholkar commited on
Commit
084d6a6
·
verified ·
1 Parent(s): d119a29

Create start.sh

Browse files
Files changed (1) hide show
  1. start.sh +40 -0
start.sh ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ echo "== Runtime environment =="
5
+ echo "Python: $(python --version)"
6
+ echo "Pip: $(python -m pip --version || true)"
7
+ echo "User: $(id)"
8
+ echo "Workdir: $(pwd)"
9
+ echo "Listing /app:"
10
+ ls -la /app || true
11
+ echo "PORT is: ${PORT:-7860}"
12
+
13
+ # Convert any CRLF to LF for safety (no-op if dos2unix not present)
14
+ if command -v dos2unix >/dev/null 2>&1; then
15
+ find /app -type f -maxdepth 1 -name "*.py" -print -exec dos2unix {} \; || true
16
+ fi
17
+
18
+ # Sanity test: can we bind to the port?
19
+ python - <<'PY'
20
+ import os, socket, sys
21
+ port = int(os.environ.get("PORT", "7860"))
22
+ s = socket.socket()
23
+ try:
24
+ s.bind(("0.0.0.0", port))
25
+ s.close()
26
+ print(f"Bind check passed on port {port}.")
27
+ except OSError as e:
28
+ print(f"Bind check failed on port {port}: {e}", file=sys.stderr)
29
+ sys.exit(1)
30
+ PY
31
+
32
+ # Show installed packages (short)
33
+ python - <<'PY'
34
+ import pkgutil
35
+ mods = sorted(m.name for m in pkgutil.iter_modules())
36
+ print("Some installed modules:", ", ".join(mods[:30]), "...")
37
+ PY
38
+
39
+ echo "== Launching Streamlit =="
40
+ exec streamlit run app.py --server.port="${PORT:-7860}" --server.address=0.0.0.0 --server.enableCORS=false --server.enableXsrfProtection=false --logger.level=debug