Simplify deployment - use physics pause instead of container shutdown
- IDLE_PAUSE_SECONDS replaces IDLE_TIMEOUT_MINUTES - Container stays running, physics pauses when idle - No restart mechanism needed - Remove wakeup service (no longer needed)
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
# Get this from: Cloudflare Zero Trust > Networks > Tunnels > Create > Docker
|
||||
CLOUDFLARE_TUNNEL_TOKEN=your-tunnel-token-here
|
||||
|
||||
# Idle auto-shutdown (minutes)
|
||||
# App exits after this many minutes with no active viewers
|
||||
# Set to 0 to disable (app runs forever)
|
||||
IDLE_TIMEOUT_MINUTES=30
|
||||
# Idle auto-pause (seconds)
|
||||
# Physics engine pauses after this many seconds with no viewers
|
||||
# CPU drops to ~0% when paused, resumes instantly on visit
|
||||
IDLE_PAUSE_SECONDS=30
|
||||
|
||||
@@ -4,9 +4,9 @@ services:
|
||||
context: ..
|
||||
dockerfile: Dockerfile
|
||||
container_name: py-dvt-ate-streamlit
|
||||
restart: "no" # Don't auto-restart - we want it to stay stopped when idle
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- IDLE_TIMEOUT_MINUTES=${IDLE_TIMEOUT_MINUTES:-30}
|
||||
- IDLE_PAUSE_SECONDS=${IDLE_PAUSE_SECONDS:-30} # Pause physics after 30s idle
|
||||
expose:
|
||||
- "8080"
|
||||
volumes:
|
||||
@@ -39,26 +39,6 @@ services:
|
||||
networks:
|
||||
- dvt-ate
|
||||
|
||||
# Optional: Auto-start streamlit when stopped (checks every 30s)
|
||||
# Uncomment if you want fully automatic restart on visit
|
||||
# wakeup:
|
||||
# image: docker:cli
|
||||
# container_name: py-dvt-ate-wakeup
|
||||
# restart: unless-stopped
|
||||
# entrypoint: /bin/sh
|
||||
# command:
|
||||
# - -c
|
||||
# - |
|
||||
# while true; do
|
||||
# sleep 30
|
||||
# if ! docker inspect -f '{{.State.Running}}' py-dvt-ate-streamlit 2>/dev/null | grep -q true; then
|
||||
# echo "[$(date)] Starting streamlit..."
|
||||
# docker start py-dvt-ate-streamlit
|
||||
# fi
|
||||
# done
|
||||
# volumes:
|
||||
# - /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
|
||||
networks:
|
||||
dvt-ate:
|
||||
driver: bridge
|
||||
|
||||
@@ -2,37 +2,22 @@
|
||||
|
||||
Deploy the DVT Simulation Platform dashboard with Cloudflare Tunnel for public access.
|
||||
|
||||
## Idle Auto-Shutdown
|
||||
## Idle Auto-Pause
|
||||
|
||||
The app automatically shuts down after a period of inactivity to save resources.
|
||||
The physics simulation automatically pauses when no one is viewing the dashboard.
|
||||
|
||||
**Configuration:**
|
||||
```bash
|
||||
# In .env or docker-compose.yml
|
||||
IDLE_TIMEOUT_MINUTES=30 # Shutdown after 30 min idle (0 = disabled)
|
||||
IDLE_PAUSE_SECONDS=30 # Pause physics after 30s idle
|
||||
```
|
||||
|
||||
**Behaviour:**
|
||||
- App tracks activity when someone has the dashboard open
|
||||
- After `IDLE_TIMEOUT_MINUTES` with no viewers, the container exits
|
||||
- nginx will show a 502 error until the container is restarted
|
||||
|
||||
**Restart Options:**
|
||||
|
||||
1. **Manual restart** (simplest):
|
||||
```bash
|
||||
docker start py-dvt-ate-streamlit
|
||||
```
|
||||
|
||||
2. **Auto-restart on poll** (uncomment `wakeup` service in docker-compose.yml):
|
||||
- Checks every 30 seconds if streamlit is stopped
|
||||
- Automatically restarts it
|
||||
- Adds ~30 second delay before app is available
|
||||
|
||||
3. **Always running** (set `IDLE_TIMEOUT_MINUTES=0`):
|
||||
- App never auto-shuts down
|
||||
- Uses minimal CPU when idle (~0.1%)
|
||||
- Memory stays allocated (~300-400MB)
|
||||
- When someone views the dashboard, physics runs normally
|
||||
- After `IDLE_PAUSE_SECONDS` with no viewers, physics engine pauses
|
||||
- CPU drops to ~0% while paused
|
||||
- Physics resumes instantly when someone visits
|
||||
- Container stays running (no restart needed)
|
||||
|
||||
## Architecture
|
||||
|
||||
|
||||
Reference in New Issue
Block a user