Skip to content

Commit 994baf3

Browse files
committed
Add loading page
1 parent 7966b8a commit 994baf3

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ This mod gives SWAG the ability to start containers on-demand when accessed thro
3232
environment:
3333
- SWAG_ONDEMAND_STOP_THRESHOLD=1800
3434
```
35+
- *Optional* - Instead of showing a 502 error page, it can display a loading page and auto-refresh once the container is up.
36+
37+
Add the following to each proxy-conf where you wish to show the loading page under `include /config/nginx/ssl.conf;`:
38+
```nginx
39+
include /config/nginx/ondemand.conf;
40+
```
3541

3642
## Labels:
3743
- `swag_ondemand=enable` - required for on-demand.

root/defaults/ondemand.conf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
proxy_intercept_errors on;
2+
error_page 502 = @waking_up;
3+
location @waking_up {
4+
add_header Retry-After 5 always;
5+
default_type text/html;
6+
return 502 '<!DOCTYPE html>
7+
<html>
8+
<head>
9+
<title>Waking Up...</title>
10+
<meta http-equiv="refresh" content="5">
11+
<style>body{font-family:sans-serif;text-align:center;padding-top:50px;}</style>
12+
</head>
13+
<body>
14+
<h1>Application is sleeping</h1>
15+
<p>Please wait while it wakes up...</p>
16+
<p>This page will refresh automatically.</p>
17+
</body>
18+
</html>';
19+
}

root/etc/s6-overlay/s6-rc.d/init-mod-swag-ondemand-setup/run

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/with-contenv bash
22

3+
echo "Applying the swag-ondemand mod..."
4+
35
if [ ! -S /var/run/docker.sock ] && [ -z "$DOCKER_HOST" ]; then
46
echo "**** Docker mod not set up properly, skipping SWAG auto-proxy ****"
57
exit 0
@@ -13,3 +15,9 @@ if ! pip list 2>&1 | grep -q "docker"; then
1315
else
1416
echo "**** docker-py already installed, skipping ****"
1517
fi
18+
19+
if [ ! -f /config/nginx/dbip.conf ]; then
20+
cp /defaults/ondemand.conf /config/nginx/ondemand.conf
21+
fi
22+
23+
echo "Applied the swag-ondemand mod"

0 commit comments

Comments
 (0)