From d4e8aab75cf73e97fdeff55f44bfa7a9cb99a73c Mon Sep 17 00:00:00 2001 From: Matteo Nastasi Date: Wed, 7 Oct 2026 09:22:27 +0200 Subject: [PATCH] answer with a static page when the daemon cannot be reached 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 , 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--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) --- INSTALL.sh | 14 +++++++-- system/nginx/brisk-daemon.inc | 4 +++ system/nginx/brisk.conf | 5 ++-- web/daemon-down.html | 53 +++++++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 web/daemon-down.html diff --git a/INSTALL.sh b/INSTALL.sh index 1d5ec55..10fd27f 100755 --- a/INSTALL.sh +++ b/INSTALL.sh @@ -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 +if [ -f "${web_path}__/daemon-down.html" ]; then + sed -i "s@@@" "${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 diff --git a/system/nginx/brisk-daemon.inc b/system/nginx/brisk-daemon.inc index 5edb8b7..3a0ecaf 100644 --- a/system/nginx/brisk-daemon.inc +++ b/system/nginx/brisk-daemon.inc @@ -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; diff --git a/system/nginx/brisk.conf b/system/nginx/brisk.conf index f062189..4e21920 100644 --- a/system/nginx/brisk.conf +++ b/system/nginx/brisk.conf @@ -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 index 0000000..a15f2d8 --- /dev/null +++ b/web/daemon-down.html @@ -0,0 +1,53 @@ + + + + + + +Brisk: errore! + + + + + + +
+ brisk
+ briscola chiamata in salsa ajax +
+
+ C'è qualche problema sul server.

+ Tra qualche istante questa pagina proverà a riconnettersi automaticamente.

+ Ci dispiace del disagio.

+ There is a problem on the server: this page will reconnect by itself in a few moments. +
+ + + -- 2.47.3