]> mop.ddnsfree.com - git repositories - brisk.git/commitdiff
answer with a static page when the daemon cannot be reached
authorMatteo Nastasi <nastasi@alternativeoutput.it>
Wed, 7 Oct 2026 07:22:27 +0000 (09:22 +0200)
committerMatteo Nastasi <nastasi@alternativeoutput.it>
Wed, 7 Oct 2026 07:22:27 +0000 (09:22 +0200)
The daemon urls fell back on error.php for 502, 503 and 504. error.php
needs php-fpm and the database, and when the front sends its php pages to
the daemon machine those are down together with the daemon: the courtesy
page failed exactly when it was needed, and the browser got a bare error.

daemon-down.html carries the same message with no php at all, and reloads
the room after 15 to 25 seconds, as error.php does, so that the players do
not all knock in the same instant when the daemon comes back; a meta
refresh covers browsers without javascript. The banners of error.php are
left out.

nginx serves it with an internal redirect, so the browser still shows the
url it asked for, briskin5/index.php included: every path in the page goes
through <base>, which INSTALL.sh rewrites with the prefix, as it does for
cookiepath. It is installed with -m full and -m front, where nginx runs,
not with -m server. The generated nginx-<name>-daemon.inc and the
brisk-daemon.inc template point error_page at it.

Checked with a -m front installation whose daemon ports are closed: every
daemon url, briskin5 and a POST to index_wr.php included, answers with the
page and keeps the 502 status, and the images it asks for answer 200.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
INSTALL.sh
system/nginx/brisk-daemon.inc
system/nginx/brisk.conf
web/daemon-down.html [new file with mode: 0644]

index 1d5ec5556f51d4d64c76524541105e325fa8d34f..10fd27f13c20dbe97b4c857a93e85e72c9172b47 100755 (executable)
@@ -370,8 +370,10 @@ proxy_set_header        X-Forwarded-Proto \$scheme;
 proxy_set_header        Upgrade           \$http_upgrade;
 proxy_set_header        Connection        \$${var}_connection_upgrade;
 
-# the courtesy page when the daemon is down
-error_page              502 503 504 ${pfx}/error.php;
+# the courtesy page when the daemon cannot be reached: static, served from
+# this machine, because error.php needs php-fpm and the database, which may
+# be down together with the daemon
+error_page              502 503 504 ${pfx}/daemon-down.html;
 EOF
     ngx_put "$tmp" "$inc_f"
 
@@ -809,7 +811,8 @@ find_names=( -name '.htaccess' -o -name '*.php' -o -name '*.phh' -o -name '*.pho
              -o -name '*.js' -o -name 'LICENSE' -o -name 'VENDOR.txt'
              -o -name 'terms-of-service*' )
 if [ "$install_mode" != "server" ]; then
-    find_names+=( -o -name '*.css' -o -name '*.mp3' -o -name '*.swf' )
+    find_names+=( -o -name '*.css' -o -name '*.mp3' -o -name '*.swf'
+                  -o -name 'daemon-down.html' )
 fi
 for i in $(find web "${find_names[@]}" | sed 's/^....//g'); do
     install -m 644 "web/$i" "${web_path}__/$i"
@@ -885,6 +888,11 @@ fi
 
 sed -i "s@var \+cookiepath \+= \+\"[^\"]*\";@var cookiepath = \"$prefix_path\";@g" ${web_path}__/commons.js
 
+# the courtesy page of nginx reaches its images and the room through <base>
+if [ -f "${web_path}__/daemon-down.html" ]; then
+    sed -i "s@<base href=\"[^\"]*\">@<base href=\"$prefix_path\">@" "${web_path}__/daemon-down.html"
+fi
+
 sed -i "s@\( \+cookiepath *: *\)\"[^\"]*\" *,@\1 \"$prefix_path\",@g" ${web_path}__/xynt-streaming.js
 
 # The root of the site is needed for two things: substituting
index 5edb8b79e73104878b5979c1d5afeb3a77469e09..3a0ecaf3934da6a3606aa3418c569288b0918b92 100644 (file)
@@ -29,3 +29,7 @@ proxy_set_header        X-Real-Ip         $remote_addr;
 proxy_set_header        X-Forwarded-Proto $scheme;
 proxy_set_header        Upgrade           $http_upgrade;
 proxy_set_header        Connection        $connection_upgrade;
+
+# the courtesy page when the daemon cannot be reached: static, because
+# error.php needs php-fpm and the database, which may be down as well
+error_page              502 503 504 /brisk/daemon-down.html;
index f0621891df4ee4764b170681bf438ffcb7b39d18..4e219204e99462f4ca62044c266be7f01a1b4f38 100644 (file)
@@ -127,7 +127,8 @@ server {
 
     location / { try_files $uri $uri/ =404; }
 
-    # error.php is the daemon courtesy page (it was ErrorDocument 500 in the
-    # apache configuration)
+    # error.php was the daemon courtesy page (ErrorDocument 500 in the apache
+    # configuration). The daemon urls now answer with the static
+    # daemon-down.html (see brisk-daemon.inc); this covers the rest.
     error_page 500 502 503 504 /error.php;
 }
diff --git a/web/daemon-down.html b/web/daemon-down.html
new file mode 100644 (file)
index 0000000..a15f2d8
--- /dev/null
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<!--
+  brisk - daemon-down.html
+
+  The courtesy page nginx answers with when the brisk-spush daemon cannot be
+  reached (error_page 502 503 504 in the configuration of the daemon urls).
+  It is static on purpose: error.php needs php-fpm and the database, and
+  when the front sends its php pages to the daemon machine those are down
+  together with the daemon.
+
+  nginx serves it with an internal redirect, so the browser still shows the
+  url it asked for, which may be <prefix>briskin5/index.php: every path
+  below goes through <base>, rewritten by INSTALL.sh with the prefix (-P).
+-->
+<html>
+<head>
+<meta charset="utf-8">
+<base href="/brisk/">
+<title>Brisk: errore!</title>
+<!-- fallback for browsers without javascript -->
+<noscript><meta http-equiv="refresh" content="20;url=./"></noscript>
+<link rel="shortcut icon" href="img/brisk_ico.png">
+<style>
+body {
+    margin: 0;
+    font-family: sans-serif;
+    background-image: url('img/saddysunbg.png');
+    text-align: center;
+}
+.headline { padding-top: 16px; font-size: 16px; }
+.content  { padding: 160px 16px 0 16px; font-size: 18px; line-height: 1.5; }
+.en       { font-size: 15px; color: #404040; }
+</style>
+</head>
+<body>
+<div class="headline">
+  <img src="img/brisk_logo64.png" alt="brisk"><br>
+  briscola chiamata in salsa ajax
+</div>
+<div class="content">
+  C'è qualche problema sul server.<br><br>
+  Tra qualche istante questa pagina proverà a riconnettersi automaticamente.<br><br>
+  Ci dispiace del disagio.<br><br>
+  <span class="en">There is a problem on the server: this page will reconnect by itself in a few moments.</span>
+</div>
+<script>
+// between 15 and 25 seconds, as error.php does: when the daemon comes back
+// the players do not all knock in the same instant
+setTimeout(function () { window.location.href = document.baseURI; },
+           (15 + Math.floor(Math.random() * 11)) * 1000);
+</script>
+</body>
+</html>