Add a public health probe and monitoring runbook (#166)
* move theme picker position in add endgames form * Add branded favicons and web manifest - Replace the placeholder favicon with the knight mark: .ico (16/32/48), SVG, and 16/32 PNGs. - Add opaque apple-touch and Android launcher icons plus a site webmanifest naming the app and using the brand palette. - Link the icon set, manifest, and theme-color from the root layout and the 404/500 pages. - Whitelist the new static files in static_paths/0 and the prelaunch allowlist so they are served in production and behind the gate. - Sync the coming-soon site's favicon.ico and drop the unused Phoenix logo. * Add a public health probe and monitoring runbook Probe https://<PHX_HOST>/health through Cloudflare every two minutes and report to a healthchecks.io check. A healthy run posts the raw health JSON; a tablebase mismatch is a green check-in with the mismatch recorded; a non-200, non-JSON, down database or network failure posts one fail ping with the response body and a loopback cross-check as evidence. --dry-run evaluates the success, degraded, fail, non-JSON and unreachable fixtures without reading config or touching the network. The runbook covers the healthchecks.io check, install, what /health proves, Beszel's blind spot and the drills. * Fix theme picker search after moving it into the endgame form The picker moved inside the endgame form, which nested the component's own <form>. Browsers, and the LiveView test DOM, drop a nested form along with its phx-change and phx-submit bindings, so the search box did nothing and three form tests lost their #theme-form selector. The component now renders no form: phx-change sits on the search input, which works both inside the endgame form and standalone on the bulk importer. The unreachable create_theme_from_search handlers go away; theme creation uses the existing button. Tests search through the input and click that button.
@@ -100,6 +100,10 @@ DNS:
|
|||||||
`/etc/chesstrainer/postgres.env` holds the Postgres container credentials,
|
`/etc/chesstrainer/postgres.env` holds the Postgres container credentials,
|
||||||
also `root:root` and `0600`.
|
also `root:root` and `0600`.
|
||||||
|
|
||||||
|
`/etc/chesstrainer/probe.env` holds the public probe's URL and its
|
||||||
|
healthchecks.io ping URL, also `root:root` and `0600`. See §Monitoring and
|
||||||
|
alerting.
|
||||||
|
|
||||||
The app runs as the dedicated `chesstrainer` system user. It must own
|
The app runs as the dedicated `chesstrainer` system user. It must own
|
||||||
`/opt/chesstrainer` so it can write `priv/static/backups`.
|
`/opt/chesstrainer` so it can write `priv/static/backups`.
|
||||||
|
|
||||||
@@ -752,7 +756,9 @@ curl -i http://127.0.0.1:4100/health
|
|||||||
|
|
||||||
`/health` returns JSON with `status`, `db`, `tablebase`, and `process`.
|
`/health` returns JSON with `status`, `db`, `tablebase`, and `process`.
|
||||||
It returns 200 for `ok`/`degraded` and 503 for `down`. A missing local tablebase
|
It returns 200 for `ok`/`degraded` and 503 for `down`. A missing local tablebase
|
||||||
reports `degraded` but still 200 because Lichess fallback is available.
|
reports `degraded` but still 200 because Lichess fallback is available. See
|
||||||
|
§Monitoring and alerting for the public probe that watches it, and for what a
|
||||||
|
green check does and does not prove.
|
||||||
|
|
||||||
### Reading production logs
|
### Reading production logs
|
||||||
|
|
||||||
@@ -800,6 +806,183 @@ Set `Storage=persistent` and a `SystemMaxUse=` value in
|
|||||||
rate-limits bursts; if a crash storm drops lines, raise `RateLimitBurst` or
|
rate-limits bursts; if a crash storm drops lines, raise `RateLimitBurst` or
|
||||||
`RateLimitIntervalSec` there.
|
`RateLimitIntervalSec` there.
|
||||||
|
|
||||||
|
## Monitoring and alerting
|
||||||
|
|
||||||
|
Three checks watch production at three different layers:
|
||||||
|
|
||||||
|
| Where | What | Notices | Alerts |
|
||||||
|
|---|---|---|---|
|
||||||
|
| VPS | `chesstrainer-probe.timer` → `chesstrainer-probe.service` | the user-facing HTTP path: DNS, Cloudflare, Caddy, Phoenix, Postgres | healthchecks.io |
|
||||||
|
| VPS | Beszel hub + agent | host liveness, CPU, memory, disk, container restarts and OOM kills | Beszel notifications |
|
||||||
|
| VPS | `chesstrainer-backup.timer` heartbeat | whether the nightly dump finished | healthchecks.io (its own check) |
|
||||||
|
|
||||||
|
The backup heartbeat is documented in §Backups. The probe and the Beszel gap
|
||||||
|
are below.
|
||||||
|
|
||||||
|
### On-box prober, off-box alerting
|
||||||
|
|
||||||
|
The probe runs on the VPS and curls the **public** hostname, so it crosses the
|
||||||
|
same path a visitor does: Cloudflare's DNS and edge, the proxy back to Caddy,
|
||||||
|
Caddy's Cloudflare allowlist, the Phoenix router, and one database query.
|
||||||
|
|
||||||
|
That is deliberately not `127.0.0.1:4100`. A loopback probe stays green through
|
||||||
|
every failure that makes the site unusable: a bad `cloudflare-ranges.caddy`
|
||||||
|
reload, a stopped Caddy (`521`), an expired origin certificate (`526`), a
|
||||||
|
deleted proxied DNS record, a WAF rule blocking `/health`, or a Cloudflare
|
||||||
|
incident. Beszel is green through all of those too, because the host and the
|
||||||
|
container are fine.
|
||||||
|
|
||||||
|
The trade-off is that the prober shares a host with the app. It cannot report
|
||||||
|
that its own host is down, and it cannot prove the view from another network.
|
||||||
|
Host death is caught by **silence**: the timer stops, no ping arrives, and
|
||||||
|
healthchecks.io — which is off-box — alerts after the grace period. That is the
|
||||||
|
whole reason the check-in URL points at a SaaS rather than at another box here.
|
||||||
|
Do not describe this as external uptime monitoring.
|
||||||
|
|
||||||
|
### The healthchecks.io check
|
||||||
|
|
||||||
|
Create the check at healthchecks.io:
|
||||||
|
|
||||||
|
- Name `innersquare.app /health`, period **2 minutes**, grace **2 minutes**
|
||||||
|
- Integrations: email and Discord (webhook). Use each integration's test
|
||||||
|
notification once, and keep recovery notifications enabled so a resolved
|
||||||
|
incident is visible.
|
||||||
|
- Copy the ping URL. It is a secret: anyone who has it can mark the check
|
||||||
|
green. It belongs only in the root-owned env file.
|
||||||
|
|
||||||
|
Every check-in carries evidence:
|
||||||
|
|
||||||
|
- A healthy run posts the raw `/health` JSON.
|
||||||
|
- A tablebase mismatch still posts a **success**, because a Lichess fallback is
|
||||||
|
not an outage. The body carries the expected and actual values, so the
|
||||||
|
mismatch is visible in the check history without alerting anyone.
|
||||||
|
- A non-200, a malformed body, a `db` that is not `ok`, or a network/TLS
|
||||||
|
failure posts to `<ping-url>/fail` with a JSON body containing the reason,
|
||||||
|
the HTTP status, the curl exit code, the response body, and a loopback
|
||||||
|
`origin_status`/`origin_body` for comparison. The origin fields are evidence
|
||||||
|
only; the verdict comes from the public request.
|
||||||
|
|
||||||
|
A ping that cannot be delivered is a journal warning, not a second verdict:
|
||||||
|
the next timer run reports the state again.
|
||||||
|
|
||||||
|
### Install the probe
|
||||||
|
|
||||||
|
Write the env file, root-owned and `0600`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo install -m 600 /dev/null /etc/chesstrainer/probe.env
|
||||||
|
sudoedit /etc/chesstrainer/probe.env
|
||||||
|
```
|
||||||
|
|
||||||
|
Start from `deploy/probe.env.example`. `PROBE_URL` and `HEALTHCHECK_URL` are the
|
||||||
|
only required values. Then install the script, the units, and the timer:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo install -m 0755 /opt/chesstrainer/src/deploy/probe \
|
||||||
|
/usr/local/sbin/chesstrainer-probe
|
||||||
|
sudo install -m 0644 \
|
||||||
|
/opt/chesstrainer/src/deploy/chesstrainer-probe.service \
|
||||||
|
/opt/chesstrainer/src/deploy/chesstrainer-probe.timer \
|
||||||
|
/etc/systemd/system/
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl enable --now chesstrainer-probe.timer
|
||||||
|
```
|
||||||
|
|
||||||
|
Verify:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
systemctl list-timers chesstrainer-probe.timer
|
||||||
|
sudo journalctl -u chesstrainer-probe -n 5 -o cat
|
||||||
|
```
|
||||||
|
|
||||||
|
Expect a `probe.ok` line every two minutes and a green check within one period.
|
||||||
|
Each run prints exactly one JSON line (`probe.ok`, `probe.degraded` or
|
||||||
|
`probe.failed`), like the backup script, so #140's log shipping can pick it up.
|
||||||
|
|
||||||
|
### What `/health` does and does not mean
|
||||||
|
|
||||||
|
`/health` returns `status`, `db`, `tablebase` and `process`. It returns 200 for
|
||||||
|
`ok` and `degraded`, and 503 for `down`.
|
||||||
|
|
||||||
|
- `db` is one `SELECT 1` through the connection pool. It proves the pool can
|
||||||
|
reach Postgres. It does not prove migrations are current or that writes work.
|
||||||
|
- `tablebase` reflects the local Syzygy directory. `fallback` means lookups go
|
||||||
|
to Lichess. `degraded` is 200 because the fallback is usable.
|
||||||
|
- `process` is always `"ok"`. It is not independent evidence of liveness.
|
||||||
|
|
||||||
|
A green probe therefore means: DNS resolved, Cloudflare served the request,
|
||||||
|
Caddy routed it under the Cloudflare allowlist, Phoenix answered, and Postgres
|
||||||
|
answered one query. It does not mean background jobs are running, SES accepts
|
||||||
|
mail, writes succeed, tablebase lookups are fast, or the site is fast under
|
||||||
|
load. Beszel covers resource exhaustion and container restarts; the release
|
||||||
|
health check and the logs cover deploy mistakes.
|
||||||
|
|
||||||
|
### Beszel's blind spot
|
||||||
|
|
||||||
|
Beszel watches the host: agent connection, CPU, memory, disk, container
|
||||||
|
restarts, OOM kills. Its hub runs on the same VPS as the agent, so a VPS
|
||||||
|
outage or network loss silences it as well — that case is covered by the probe
|
||||||
|
check going quiet. More importantly, Beszel never calls `/health`. A Phoenix
|
||||||
|
release returning 500s on a healthy host, or Postgres refusing connections
|
||||||
|
inside a running container, reads green in Beszel and red in the probe. The two
|
||||||
|
are complementary, not redundant.
|
||||||
|
|
||||||
|
### Drills
|
||||||
|
|
||||||
|
Nothing below touches production data, and the app keeps serving throughout.
|
||||||
|
|
||||||
|
`--dry-run` needs no network and no env file. It evaluates the success,
|
||||||
|
degraded, fail, non-JSON and unreachable fixtures and sends no check-ins:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo /usr/local/sbin/chesstrainer-probe --dry-run
|
||||||
|
```
|
||||||
|
|
||||||
|
A degraded check-in, recorded but never alerting. A value passed on the command
|
||||||
|
line wins over the env file:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo EXPECT_TABLEBASE=not_configured /usr/local/sbin/chesstrainer-probe
|
||||||
|
```
|
||||||
|
|
||||||
|
Expect exit 0, a green check, and a body showing `tablebase: local` against
|
||||||
|
`expected_tablebase: not_configured`. No email and no Discord message.
|
||||||
|
|
||||||
|
The one fail ping, and the full alert path. Stop the timer first so the next
|
||||||
|
scheduled run cannot mask the result:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo systemctl stop chesstrainer-probe.timer
|
||||||
|
sudo PROBE_URL=https://innersquare.app/health-does-not-exist \
|
||||||
|
/usr/local/sbin/chesstrainer-probe
|
||||||
|
```
|
||||||
|
|
||||||
|
Expect exit 1, one `probe.failed` line with `http_status: 404`, one fail ping
|
||||||
|
whose body shows `origin_status: 200`, one alert in Discord/email, and no
|
||||||
|
second fail ping. Then send a real check-in and re-arm:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo /usr/local/sbin/chesstrainer-probe
|
||||||
|
sudo systemctl start chesstrainer-probe.timer
|
||||||
|
```
|
||||||
|
|
||||||
|
The real run posts a success, and healthchecks.io notifies that the check is
|
||||||
|
back up. For the unreachable branch, point the probe at a closed port instead;
|
||||||
|
the origin evidence should still show `200`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo PROBE_URL=https://127.0.0.1:9/health /usr/local/sbin/chesstrainer-probe
|
||||||
|
```
|
||||||
|
|
||||||
|
Planned maintenance: stopping the timer is reported as a down check after
|
||||||
|
period plus grace, so about four minutes. Pause the check in the healthchecks.io
|
||||||
|
UI for the duration, or accept the alert.
|
||||||
|
|
||||||
|
The probe reaches the edge as a plain `curl`. If a bot policy or WAF rule ever
|
||||||
|
starts rejecting it, the fail body's `origin_status` shows the app itself is
|
||||||
|
healthy; that is an edge-policy change, not an application outage. Re-enabling
|
||||||
|
Bot Fight Mode is tracked in #153.
|
||||||
|
|
||||||
## Interactive shell and user management
|
## Interactive shell and user management
|
||||||
|
|
||||||
Attach an IEx shell to the **running** release. This does not restart the
|
Attach an IEx shell to the **running** release. This does not restart the
|
||||||
@@ -1223,5 +1406,7 @@ restore over `chesstrainer_prod` while the application is running.
|
|||||||
globals file.
|
globals file.
|
||||||
12. Workstation age key and pull configuration installed, user timers and linger
|
12. Workstation age key and pull configuration installed, user timers and linger
|
||||||
enabled, first pull verified, first drill passes.
|
enabled, first pull verified, first drill passes.
|
||||||
13. Remote shell attaches and exits cleanly:
|
13. `/etc/chesstrainer/probe.env` written, probe script and units installed,
|
||||||
|
timer enabled, and the healthchecks.io check green within one period.
|
||||||
|
14. Remote shell attaches and exits cleanly:
|
||||||
`sudo /opt/chesstrainer/current/bin/chesstrainer remote` (Ctrl-C twice).
|
`sudo /opt/chesstrainer/current/bin/chesstrainer remote` (Ctrl-C twice).
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Probe the public Inner Square Chess app and report to healthchecks.io
|
||||||
|
Documentation=https://github.com/TheRealOwenRees/chess-endgame-trainer/blob/main/deploy/README.md
|
||||||
|
After=network-online.target
|
||||||
|
Wants=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
User=root
|
||||||
|
Group=root
|
||||||
|
ExecStart=/usr/local/sbin/chesstrainer-probe
|
||||||
|
TimeoutStartSec=90s
|
||||||
|
SyslogIdentifier=chesstrainer-probe
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Probe the public Inner Square Chess app every two minutes
|
||||||
|
Documentation=https://github.com/TheRealOwenRees/chess-endgame-trainer/blob/main/deploy/README.md
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnBootSec=30s
|
||||||
|
OnUnitActiveSec=2min
|
||||||
|
AccuracySec=5s
|
||||||
|
Unit=chesstrainer-probe.service
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
||||||
@@ -0,0 +1,359 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Probe the public Inner Square Chess app and report the verdict to
|
||||||
|
# healthchecks.io.
|
||||||
|
#
|
||||||
|
# Installed as /usr/local/sbin/chesstrainer-probe (root-owned 0755) and run by
|
||||||
|
# chesstrainer-probe.timer every two minutes. The probe deliberately goes
|
||||||
|
# through the public hostname, not loopback: DNS, Cloudflare, Caddy and the
|
||||||
|
# origin allowlist are part of what a visitor depends on. A loopback health
|
||||||
|
# URL is still consulted on failure, as evidence only.
|
||||||
|
#
|
||||||
|
# sudo /usr/local/sbin/chesstrainer-probe
|
||||||
|
# sudo /usr/local/sbin/chesstrainer-probe --dry-run # no network, no config
|
||||||
|
#
|
||||||
|
# Configuration lives in /etc/chesstrainer/probe.env (root:root 0600). See
|
||||||
|
# deploy/README.md §Monitoring and alerting. Individual settings can be passed
|
||||||
|
# as environment variables to a manual run, which is how the drills vary the
|
||||||
|
# URL and the expected tablebase.
|
||||||
|
#
|
||||||
|
# Each run prints exactly one JSON line (probe.ok, probe.degraded or
|
||||||
|
# probe.failed) so journald, and #140's log shipping, can pick it up.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
umask 077
|
||||||
|
|
||||||
|
ENV_FILE="${ENV_FILE:-/etc/chesstrainer/probe.env}"
|
||||||
|
|
||||||
|
START_SECONDS=$SECONDS
|
||||||
|
DRY_RUN=0
|
||||||
|
TMPDIR_PROBE=""
|
||||||
|
HTTP_BODY_FILE=""
|
||||||
|
HTTP_HEADER_FILE=""
|
||||||
|
HTTP_ERROR_FILE=""
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<'EOF'
|
||||||
|
Usage: chesstrainer-probe [--dry-run]
|
||||||
|
|
||||||
|
--dry-run print the verdict for the success, degraded, fail, non-JSON and
|
||||||
|
unreachable fixtures without reading the env file or making a
|
||||||
|
network request
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
while (($# > 0)); do
|
||||||
|
case "$1" in
|
||||||
|
--dry-run) DRY_RUN=1 ;;
|
||||||
|
-h | --help)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
usage >&2
|
||||||
|
echo "probe: unknown argument: $1" >&2
|
||||||
|
exit 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
log_event() {
|
||||||
|
local event="$1"
|
||||||
|
local extra="${2:-}"
|
||||||
|
|
||||||
|
printf '{"timestamp":"%s","event":"%s"%s}\n' \
|
||||||
|
"$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$event" "$extra"
|
||||||
|
}
|
||||||
|
|
||||||
|
fail() {
|
||||||
|
echo "probe: $*" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
json_escape() {
|
||||||
|
local text="$1"
|
||||||
|
|
||||||
|
text="${text//\\/\\\\}"
|
||||||
|
text="${text//\"/\\\"}"
|
||||||
|
text="${text//$'\n'/\\n}"
|
||||||
|
text="${text//$'\r'/\\r}"
|
||||||
|
text="${text//$'\t'/\\t}"
|
||||||
|
text="$(printf '%s' "$text" | LC_ALL=C tr -d '[:cntrl:]')"
|
||||||
|
|
||||||
|
printf '%s' "$text"
|
||||||
|
}
|
||||||
|
|
||||||
|
body_snippet() {
|
||||||
|
local file="$1"
|
||||||
|
|
||||||
|
if [[ -s "$file" ]]; then
|
||||||
|
head -c "$MAX_BODY_BYTES" "$file"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
json_field() {
|
||||||
|
local key="$1"
|
||||||
|
local json="$2"
|
||||||
|
|
||||||
|
if [[ "$json" =~ \"$key\"[[:space:]]*:[[:space:]]*\"([^\"]*)\" ]]; then
|
||||||
|
printf '%s' "${BASH_REMATCH[1]}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
http_get() {
|
||||||
|
local url="$1"
|
||||||
|
local prefix="$2"
|
||||||
|
local proto="$3"
|
||||||
|
local status=""
|
||||||
|
local exit_code=0
|
||||||
|
|
||||||
|
HTTP_BODY_FILE="$prefix.body"
|
||||||
|
HTTP_HEADER_FILE="$prefix.headers"
|
||||||
|
HTTP_ERROR_FILE="$prefix.error"
|
||||||
|
: >"$HTTP_BODY_FILE"
|
||||||
|
: >"$HTTP_HEADER_FILE"
|
||||||
|
: >"$HTTP_ERROR_FILE"
|
||||||
|
|
||||||
|
if status="$(curl --silent --show-error --location \
|
||||||
|
--proto "$proto" \
|
||||||
|
--connect-timeout 5 \
|
||||||
|
--max-time "$PROBE_TIMEOUT_SECONDS" \
|
||||||
|
--output "$HTTP_BODY_FILE" \
|
||||||
|
--dump-header "$HTTP_HEADER_FILE" \
|
||||||
|
--write-out '%{http_code}' \
|
||||||
|
"$url")"; then
|
||||||
|
exit_code=0
|
||||||
|
else
|
||||||
|
exit_code=$?
|
||||||
|
fi
|
||||||
|
|
||||||
|
HTTP_STATUS="${status:-000}"
|
||||||
|
CURL_EXIT="$exit_code"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Sets VERDICT (ok, degraded, failed), REASON, DB and TABLEBASE. The database is
|
||||||
|
# the only hard dependency; a missing local tablebase still serves users from
|
||||||
|
# Lichess, so it is reported as a green but degraded check-in.
|
||||||
|
evaluate() {
|
||||||
|
local status="$1"
|
||||||
|
local exit_code="$2"
|
||||||
|
local body="$3"
|
||||||
|
local trimmed=""
|
||||||
|
|
||||||
|
VERDICT="failed"
|
||||||
|
REASON=""
|
||||||
|
DB=""
|
||||||
|
TABLEBASE=""
|
||||||
|
|
||||||
|
if ((exit_code != 0)); then
|
||||||
|
REASON="unreachable: curl exit $exit_code"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$status" != "200" ]]; then
|
||||||
|
REASON="http $status"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
trimmed="${body#"${body%%[![:space:]]*}"}"
|
||||||
|
trimmed="${trimmed%"${trimmed##*[![:space:]]}"}"
|
||||||
|
if [[ "${trimmed:0:1}" != "{" || "${trimmed: -1}" != "}" ]]; then
|
||||||
|
REASON="non-JSON response"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
DB="$(json_field db "$body")"
|
||||||
|
TABLEBASE="$(json_field tablebase "$body")"
|
||||||
|
|
||||||
|
if [[ -z "$DB" ]]; then
|
||||||
|
REASON="response has no db field"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$DB" != "ok" ]]; then
|
||||||
|
REASON="db is $DB"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$EXPECT_TABLEBASE" != "any" && "$TABLEBASE" != "$EXPECT_TABLEBASE" ]]; then
|
||||||
|
VERDICT="degraded"
|
||||||
|
REASON="tablebase is ${TABLEBASE:-unknown}, expected $EXPECT_TABLEBASE"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
VERDICT="ok"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Exactly one call site per run, and one call site per outcome, so a forced
|
||||||
|
# failure can only ever produce one fail ping.
|
||||||
|
ping_check() {
|
||||||
|
local outcome="$1"
|
||||||
|
local body="$2"
|
||||||
|
local url=""
|
||||||
|
local body_file=""
|
||||||
|
|
||||||
|
if [[ -z "$HEALTHCHECK_URL" ]]; then
|
||||||
|
echo "probe: HEALTHCHECK_URL is not set, not reporting" >&2
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
url="${HEALTHCHECK_URL%/}"
|
||||||
|
if [[ "$outcome" == "fail" ]]; then
|
||||||
|
url="$url/fail"
|
||||||
|
fi
|
||||||
|
|
||||||
|
body_file="$(mktemp)"
|
||||||
|
printf '%s' "$body" >"$body_file"
|
||||||
|
|
||||||
|
if ! curl --silent --show-error --fail \
|
||||||
|
--max-time 10 --retry 2 --retry-delay 2 \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data-binary "@$body_file" \
|
||||||
|
--output /dev/null "$url"; then
|
||||||
|
echo "probe: check-in ping failed (run result is unaffected)" >&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -f "$body_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
origin_evidence() {
|
||||||
|
local prefix="$1"
|
||||||
|
|
||||||
|
http_get "$ORIGIN_URL" "$prefix" '=https,http'
|
||||||
|
ORIGIN_STATUS="$HTTP_STATUS"
|
||||||
|
ORIGIN_EXIT="$CURL_EXIT"
|
||||||
|
ORIGIN_BODY="$(body_snippet "$HTTP_BODY_FILE")"
|
||||||
|
ORIGIN_ERROR="$(body_snippet "$HTTP_ERROR_FILE")"
|
||||||
|
}
|
||||||
|
|
||||||
|
fail_evidence() {
|
||||||
|
local evidence=""
|
||||||
|
|
||||||
|
evidence="$(printf '{"probe":"failed","reason":"%s","url":"%s","http_status":"%s","curl_exit":%s' \
|
||||||
|
"$(json_escape "$REASON")" "$(json_escape "$PROBE_URL")" "$PUBLIC_STATUS" "$PUBLIC_EXIT")"
|
||||||
|
|
||||||
|
if [[ -n "$ERROR_TEXT" ]]; then
|
||||||
|
evidence+="$(printf ',"error":"%s"' "$(json_escape "$ERROR_TEXT")")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$BODY" ]]; then
|
||||||
|
evidence+="$(printf ',"body":"%s"' "$(json_escape "$BODY")")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
evidence+="$(printf ',"origin_url":"%s","origin_status":"%s","origin_curl_exit":%s' \
|
||||||
|
"$(json_escape "$ORIGIN_URL")" "$ORIGIN_STATUS" "$ORIGIN_EXIT")"
|
||||||
|
|
||||||
|
if [[ -n "$ORIGIN_BODY" ]]; then
|
||||||
|
evidence+="$(printf ',"origin_body":"%s"' "$(json_escape "$ORIGIN_BODY")")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$ORIGIN_ERROR" ]]; then
|
||||||
|
evidence+="$(printf ',"origin_error":"%s"' "$(json_escape "$ORIGIN_ERROR")")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf '%s}' "$evidence"
|
||||||
|
}
|
||||||
|
|
||||||
|
dry_run() {
|
||||||
|
local -a scenarios=(
|
||||||
|
'HTTP 200, healthy|200|0|{"process":"ok","status":"ok","db":"ok","tablebase":"local"}'
|
||||||
|
'HTTP 200, tablebase fallback|200|0|{"process":"ok","status":"degraded","db":"ok","tablebase":"fallback"}'
|
||||||
|
'HTTP 503, db down|503|0|{"process":"ok","status":"down","db":"down","tablebase":"local"}'
|
||||||
|
'HTTP 200, non-JSON|200|0|<html><body>502 Bad Gateway</body></html>'
|
||||||
|
'timeout, no response|000|28|'
|
||||||
|
)
|
||||||
|
local row name status exit_code body action
|
||||||
|
|
||||||
|
printf 'probe: dry run, no network calls and no configuration read\n'
|
||||||
|
printf 'probe: every fixture is evaluated with EXPECT_TABLEBASE=local\n\n'
|
||||||
|
printf '%-28s %-9s %-46s %s\n' "scenario" "verdict" "reason" "would ping"
|
||||||
|
|
||||||
|
for row in "${scenarios[@]}"; do
|
||||||
|
IFS='|' read -r name status exit_code body <<<"$row"
|
||||||
|
EXPECT_TABLEBASE="local"
|
||||||
|
evaluate "$status" "$exit_code" "$body"
|
||||||
|
|
||||||
|
case "$VERDICT" in
|
||||||
|
ok) action="success, raw /health JSON" ;;
|
||||||
|
degraded) action="success, mismatch evidence" ;;
|
||||||
|
*) action="fail, evidence JSON" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
printf '%-28s %-9s %-46s %s\n' "$name" "$VERDICT" "${REASON:--}" "$action"
|
||||||
|
done
|
||||||
|
|
||||||
|
printf '\nprobe: dry run complete, no check-ins sent\n'
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((DRY_RUN)); then
|
||||||
|
dry_run
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Overrides passed on the command line survive the env file, so the drills can
|
||||||
|
# vary the URL or the expected tablebase without editing a root-only file.
|
||||||
|
_OVERRIDE_PROBE_URL="${PROBE_URL:-}"
|
||||||
|
_OVERRIDE_EXPECT_TABLEBASE="${EXPECT_TABLEBASE:-}"
|
||||||
|
_OVERRIDE_PROBE_TIMEOUT_SECONDS="${PROBE_TIMEOUT_SECONDS:-}"
|
||||||
|
|
||||||
|
if [[ -r "$ENV_FILE" ]]; then
|
||||||
|
# shellcheck disable=SC1090
|
||||||
|
source "$ENV_FILE"
|
||||||
|
else
|
||||||
|
fail "cannot read $ENV_FILE (set ENV_FILE to override)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
PROBE_URL="${_OVERRIDE_PROBE_URL:-${PROBE_URL:-}}"
|
||||||
|
EXPECT_TABLEBASE="${_OVERRIDE_EXPECT_TABLEBASE:-${EXPECT_TABLEBASE:-local}}"
|
||||||
|
PROBE_TIMEOUT_SECONDS="${_OVERRIDE_PROBE_TIMEOUT_SECONDS:-${PROBE_TIMEOUT_SECONDS:-10}}"
|
||||||
|
|
||||||
|
HEALTHCHECK_URL="${HEALTHCHECK_URL:-}"
|
||||||
|
ORIGIN_URL="${ORIGIN_URL:-http://127.0.0.1:4100/health}"
|
||||||
|
MAX_BODY_BYTES="${MAX_BODY_BYTES:-2000}"
|
||||||
|
|
||||||
|
[[ "$PROBE_URL" == https://* ]] || fail "PROBE_URL must be an https URL"
|
||||||
|
[[ -n "$HEALTHCHECK_URL" ]] || fail "HEALTHCHECK_URL is not set"
|
||||||
|
[[ "$EXPECT_TABLEBASE" =~ ^(local|fallback|not_configured|any)$ ]] ||
|
||||||
|
fail "EXPECT_TABLEBASE must be local, fallback, not_configured or any"
|
||||||
|
[[ "$PROBE_TIMEOUT_SECONDS" =~ ^[0-9]+$ ]] || fail "PROBE_TIMEOUT_SECONDS must be an integer"
|
||||||
|
command -v curl >/dev/null 2>&1 || fail "missing command: curl"
|
||||||
|
|
||||||
|
TMPDIR_PROBE="$(mktemp -d)"
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
if [[ -n "$TMPDIR_PROBE" && -d "$TMPDIR_PROBE" ]]; then
|
||||||
|
rm -rf "$TMPDIR_PROBE"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
trap cleanup EXIT
|
||||||
|
trap 'exit 143' TERM INT
|
||||||
|
|
||||||
|
http_get "$PROBE_URL" "$TMPDIR_PROBE/public" '=https'
|
||||||
|
PUBLIC_STATUS="$HTTP_STATUS"
|
||||||
|
PUBLIC_EXIT="$CURL_EXIT"
|
||||||
|
BODY="$(body_snippet "$HTTP_BODY_FILE")"
|
||||||
|
ERROR_TEXT="$(body_snippet "$HTTP_ERROR_FILE")"
|
||||||
|
|
||||||
|
evaluate "$PUBLIC_STATUS" "$PUBLIC_EXIT" "$BODY"
|
||||||
|
|
||||||
|
case "$VERDICT" in
|
||||||
|
ok)
|
||||||
|
log_event probe.ok ",\"status\":\"$PUBLIC_STATUS\",\"tablebase\":\"$(json_escape "$TABLEBASE")\",\"duration_s\":$((SECONDS - START_SECONDS))"
|
||||||
|
ping_check ok "$BODY"
|
||||||
|
;;
|
||||||
|
degraded)
|
||||||
|
evidence="$(printf '{"expected_tablebase":"%s","health":%s}' \
|
||||||
|
"$(json_escape "$EXPECT_TABLEBASE")" "$BODY")"
|
||||||
|
log_event probe.degraded ",\"reason\":\"$(json_escape "$REASON")\",\"tablebase\":\"$(json_escape "$TABLEBASE")\",\"duration_s\":$((SECONDS - START_SECONDS))"
|
||||||
|
ping_check ok "$evidence"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
origin_evidence "$TMPDIR_PROBE/origin"
|
||||||
|
evidence="$(fail_evidence)"
|
||||||
|
log_event probe.failed ",\"reason\":\"$(json_escape "$REASON")\",\"http_status\":\"$PUBLIC_STATUS\",\"curl_exit\":$PUBLIC_EXIT,\"duration_s\":$((SECONDS - START_SECONDS))"
|
||||||
|
ping_check fail "$evidence"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# /etc/chesstrainer/probe.env -- root:root, mode 0600.
|
||||||
|
#
|
||||||
|
# Sourced by /usr/local/sbin/chesstrainer-probe. The check-in URL is a secret:
|
||||||
|
# anyone who has it can mark the check green, so keep it out of the repo and
|
||||||
|
# out of world-readable files.
|
||||||
|
|
||||||
|
# The public URL a visitor actually requests. Probing the edge rather than
|
||||||
|
# loopback is deliberate: DNS, TLS, Cloudflare, Caddy and the origin allowlist
|
||||||
|
# are part of the contract. Must be https.
|
||||||
|
PROBE_URL=https://innersquare.app/health
|
||||||
|
|
||||||
|
# healthchecks.io ping URL for the two-minute probe check. A healthy run posts
|
||||||
|
# to it; a failed run posts to <url>/fail.
|
||||||
|
HEALTHCHECK_URL=https://hc-ping.com/00000000-0000-0000-0000-000000000000
|
||||||
|
|
||||||
|
# The tablebase value /health should report. "local" means Syzygy files are
|
||||||
|
# loaded, "fallback" means Lichess is used, "not_configured" means
|
||||||
|
# TABLEBASE_PATH is unset. A mismatch is reported as degraded, never as down.
|
||||||
|
# Set to "any" to accept whatever the app reports.
|
||||||
|
EXPECT_TABLEBASE=local
|
||||||
|
|
||||||
|
# Whole-request timeout. The timer runs every two minutes, so keep this well
|
||||||
|
# under that.
|
||||||
|
PROBE_TIMEOUT_SECONDS=10
|
||||||
|
|
||||||
|
# Loopback health URL. It is consulted only when the public probe fails, and
|
||||||
|
# only as evidence: it does not change the verdict. Defaults to the value shown.
|
||||||
|
# ORIGIN_URL=http://127.0.0.1:4100/health
|
||||||
|
Before Width: | Height: | Size: 152 B After Width: | Height: | Size: 15 KiB |
@@ -17,7 +17,11 @@ defmodule ChesstrainerWeb do
|
|||||||
those modules here.
|
those modules here.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def static_paths, do: ~w(assets fonts images favicon.ico)
|
def static_paths do
|
||||||
|
~w(assets fonts images favicon.ico favicon.svg favicon-16x16.png favicon-32x32.png
|
||||||
|
apple-touch-icon.png android-chrome-192x192.png android-chrome-512x512.png
|
||||||
|
site.webmanifest)
|
||||||
|
end
|
||||||
|
|
||||||
@doc "Whether the app is gated behind the prelaunch page."
|
@doc "Whether the app is gated behind the prelaunch page."
|
||||||
def prelaunch?, do: Application.get_env(:chesstrainer, :prelaunch, false)
|
def prelaunch?, do: Application.get_env(:chesstrainer, :prelaunch, false)
|
||||||
|
|||||||
@@ -41,6 +41,14 @@
|
|||||||
name="twitter:description"
|
name="twitter:description"
|
||||||
content={assigns[:meta_description]}
|
content={assigns[:meta_description]}
|
||||||
/>
|
/>
|
||||||
|
<link rel="icon" href="/favicon.ico" sizes="48x48" />
|
||||||
|
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
|
||||||
|
<link rel="icon" href="/favicon-32x32.png" type="image/png" sizes="32x32" />
|
||||||
|
<link rel="icon" href="/favicon-16x16.png" type="image/png" sizes="16x16" />
|
||||||
|
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
|
||||||
|
<link rel="manifest" href="/site.webmanifest" />
|
||||||
|
<meta name="theme-color" content="#17352d" />
|
||||||
|
|
||||||
<link phx-track-static rel="stylesheet" href={~p"/assets/css/app.css"} />
|
<link phx-track-static rel="stylesheet" href={~p"/assets/css/app.css"} />
|
||||||
<link
|
<link
|
||||||
rel="preload"
|
rel="preload"
|
||||||
|
|||||||
@@ -3,8 +3,12 @@ defmodule ChesstrainerWeb.ThemePicker do
|
|||||||
Search-and-select control shared by the endgame form and bulk importer.
|
Search-and-select control shared by the endgame form and bulk importer.
|
||||||
|
|
||||||
The parent LiveView owns the assignments and handles the events:
|
The parent LiveView owns the assignments and handles the events:
|
||||||
`search_themes`, `add_theme`, `create_theme`, `create_theme_from_search` and
|
`search_themes`, `add_theme`, `create_theme` and `remove_theme`.
|
||||||
`remove_theme`.
|
|
||||||
|
The control renders no `<form>` of its own. It is embedded in the endgame
|
||||||
|
form, where a nested form would be dropped by the HTML parser and take its
|
||||||
|
bindings with it, and it is used standalone on the bulk importer. Binding
|
||||||
|
`phx-change` on the search input keeps both call sites working.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
use ChesstrainerWeb, :html
|
use ChesstrainerWeb, :html
|
||||||
@@ -35,10 +39,11 @@ defmodule ChesstrainerWeb.ThemePicker do
|
|||||||
</.badge>
|
</.badge>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form id="theme-form" phx-change="search_themes" phx-submit="create_theme_from_search">
|
<div id="theme-picker">
|
||||||
<.input
|
<.input
|
||||||
name="theme_search"
|
name="theme_search"
|
||||||
value={@theme_query}
|
value={@theme_query}
|
||||||
|
phx-change="search_themes"
|
||||||
phx-debounce="200"
|
phx-debounce="200"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
placeholder="Search or create a theme…"
|
placeholder="Search or create a theme…"
|
||||||
@@ -67,7 +72,7 @@ defmodule ChesstrainerWeb.ThemePicker do
|
|||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</form>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,6 +6,14 @@
|
|||||||
<meta name="robots" content="noindex" />
|
<meta name="robots" content="noindex" />
|
||||||
<title>{Branding.title("Page not found")}</title>
|
<title>{Branding.title("Page not found")}</title>
|
||||||
|
|
||||||
|
<link rel="icon" href="/favicon.ico" sizes="48x48" />
|
||||||
|
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
|
||||||
|
<link rel="icon" href="/favicon-32x32.png" type="image/png" sizes="32x32" />
|
||||||
|
<link rel="icon" href="/favicon-16x16.png" type="image/png" sizes="16x16" />
|
||||||
|
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
|
||||||
|
<link rel="manifest" href="/site.webmanifest" />
|
||||||
|
<meta name="theme-color" content="#17352d" />
|
||||||
|
|
||||||
<link phx-track-static rel="stylesheet" href={~p"/assets/css/app.css"} />
|
<link phx-track-static rel="stylesheet" href={~p"/assets/css/app.css"} />
|
||||||
<link
|
<link
|
||||||
rel="preload"
|
rel="preload"
|
||||||
|
|||||||
@@ -6,6 +6,14 @@
|
|||||||
<meta name="robots" content="noindex" />
|
<meta name="robots" content="noindex" />
|
||||||
<title>{Branding.title("Something went wrong")}</title>
|
<title>{Branding.title("Something went wrong")}</title>
|
||||||
|
|
||||||
|
<link rel="icon" href="/favicon.ico" sizes="48x48" />
|
||||||
|
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
|
||||||
|
<link rel="icon" href="/favicon-32x32.png" type="image/png" sizes="32x32" />
|
||||||
|
<link rel="icon" href="/favicon-16x16.png" type="image/png" sizes="16x16" />
|
||||||
|
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
|
||||||
|
<link rel="manifest" href="/site.webmanifest" />
|
||||||
|
<meta name="theme-color" content="#17352d" />
|
||||||
|
|
||||||
<link phx-track-static rel="stylesheet" href={~p"/assets/css/app.css"} />
|
<link phx-track-static rel="stylesheet" href={~p"/assets/css/app.css"} />
|
||||||
<link
|
<link
|
||||||
rel="preload"
|
rel="preload"
|
||||||
|
|||||||
@@ -21,13 +21,6 @@ defmodule ChesstrainerWeb.EndgameLive.Form do
|
|||||||
<:subtitle>Use this form to manage endgame records in your database.</:subtitle>
|
<:subtitle>Use this form to manage endgame records in your database.</:subtitle>
|
||||||
</.header>
|
</.header>
|
||||||
|
|
||||||
<.theme_picker
|
|
||||||
selected_themes={@selected_themes}
|
|
||||||
theme_query={@theme_query}
|
|
||||||
theme_results={@theme_results}
|
|
||||||
can_create={@can_create}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<.form for={@form} id="endgame-form" phx-change="validate" phx-submit="save">
|
<.form for={@form} id="endgame-form" phx-change="validate" phx-submit="save">
|
||||||
<div class="flex flex-col gap-6 sm:flex-row sm:items-start">
|
<div class="flex flex-col gap-6 sm:flex-row sm:items-start">
|
||||||
<div class="min-w-0 flex-1">
|
<div class="min-w-0 flex-1">
|
||||||
@@ -40,6 +33,13 @@ defmodule ChesstrainerWeb.EndgameLive.Form do
|
|||||||
label="Rating"
|
label="Rating"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<.theme_picker
|
||||||
|
selected_themes={@selected_themes}
|
||||||
|
theme_query={@theme_query}
|
||||||
|
theme_results={@theme_results}
|
||||||
|
can_create={@can_create}
|
||||||
|
/>
|
||||||
|
|
||||||
<.input field={@form[:message]} type="textarea" label="Message" />
|
<.input field={@form[:message]} type="textarea" label="Message" />
|
||||||
<.input field={@form[:notes]} type="textarea" label="Notes" />
|
<.input field={@form[:notes]} type="textarea" label="Notes" />
|
||||||
<.input
|
<.input
|
||||||
@@ -122,10 +122,6 @@ defmodule ChesstrainerWeb.EndgameLive.Form do
|
|||||||
{:noreply, create_theme(socket, name)}
|
{:noreply, create_theme(socket, name)}
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_event("create_theme_from_search", %{"theme_search" => name}, socket) do
|
|
||||||
{:noreply, create_theme(socket, name)}
|
|
||||||
end
|
|
||||||
|
|
||||||
def handle_event("remove_theme", %{"id" => id}, socket) do
|
def handle_event("remove_theme", %{"id" => id}, socket) do
|
||||||
selected = Enum.reject(socket.assigns.selected_themes, &(Integer.to_string(&1.id) == id))
|
selected = Enum.reject(socket.assigns.selected_themes, &(Integer.to_string(&1.id) == id))
|
||||||
{:noreply, assign(socket, :selected_themes, selected)}
|
{:noreply, assign(socket, :selected_themes, selected)}
|
||||||
|
|||||||
@@ -194,10 +194,6 @@ defmodule ChesstrainerWeb.EndgameLive.Import do
|
|||||||
{:noreply, create_theme(socket, name)}
|
{:noreply, create_theme(socket, name)}
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_event("create_theme_from_search", %{"theme_search" => name}, socket) do
|
|
||||||
{:noreply, create_theme(socket, name)}
|
|
||||||
end
|
|
||||||
|
|
||||||
def handle_event("remove_theme", %{"id" => id}, socket) do
|
def handle_event("remove_theme", %{"id" => id}, socket) do
|
||||||
selected = Enum.reject(socket.assigns.selected_themes, &(Integer.to_string(&1.id) == id))
|
selected = Enum.reject(socket.assigns.selected_themes, &(Integer.to_string(&1.id) == id))
|
||||||
{:noreply, assign(socket, :selected_themes, selected)}
|
{:noreply, assign(socket, :selected_themes, selected)}
|
||||||
|
|||||||
@@ -20,6 +20,13 @@ defmodule ChesstrainerWeb.Plugs.Prelaunch do
|
|||||||
/robots.txt
|
/robots.txt
|
||||||
/sitemap.xml
|
/sitemap.xml
|
||||||
/favicon.ico
|
/favicon.ico
|
||||||
|
/favicon.svg
|
||||||
|
/favicon-16x16.png
|
||||||
|
/favicon-32x32.png
|
||||||
|
/apple-touch-icon.png
|
||||||
|
/android-chrome-192x192.png
|
||||||
|
/android-chrome-512x512.png
|
||||||
|
/site.webmanifest
|
||||||
)
|
)
|
||||||
|
|
||||||
@allowed_prefixes ~w(
|
@allowed_prefixes ~w(
|
||||||
|
|||||||
|
After Width: | Height: | Size: 9.0 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 8.2 KiB |
|
After Width: | Height: | Size: 781 B |
|
After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 152 B After Width: | Height: | Size: 15 KiB |
@@ -0,0 +1,4 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
||||||
|
<circle cx="32" cy="32" r="32" fill="#17352d"/>
|
||||||
|
<path fill="#f4f0e6" d="M28.75 19.15Q29.69 18.56 29.69 17.57Q29.69 16.94 29.31 16.21Q28.93 15.49 28.93 14.93Q28.93 13.76 30.4 13Q32.56 15.06 32.75 16.19Q32.94 17.32 32.94 17.65Q32.94 18.84 32.08 19.15H32.18Q32.18 19.17 32.13 19.17Q45.74 27.81 46.89 51H22.25Q21.92 49.58 21.92 48.1Q21.92 44.04 27.06 40.45Q32.2 36.85 32.2 33.98Q32.2 33.78 32.18 33.6Q30.5 37.84 27.53 37.84H27.28Q24.99 41.55 22.37 41.55Q22.27 41.55 22.2 41.55L23.41 38.91L20.7 40.94Q17.8 40.23 17.11 38.12Q19.35 32.3 19.35 27.48Q19.35 26.79 19.3 26.13Q20.52 23.36 23.03 20.72Q23.11 20.47 23.11 20.24Q23.11 19.53 22.54 19.2Q21.97 18.87 21.97 17.98Q21.97 17.04 22.47 15.36Q25.12 16.05 26.54 19.15ZM22.22 25.62V26.03Q22.32 26.79 22.53 26.79H23.06Q24.81 26.79 24.81 25.55Q24.81 24.68 25.9 23.47H25.75Q23.31 23.47 22.37 25.09ZM19.45 37.05V37.66Q19.45 38.4 20.16 38.4H20.42Q22.25 38.02 22.25 36.67L22.07 35.81Q20.49 35.81 19.45 37.05ZM32.1 21.18 33.42 23.44Q42.95 30.27 43.1 49.68H45.06Q43.91 28.09 32.1 21.18Z"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -1,6 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 71 48" fill="currentColor" aria-hidden="true">
|
|
||||||
<path
|
|
||||||
d="m26.371 33.477-.552-.1c-3.92-.729-6.397-3.1-7.57-6.829-.733-2.324.597-4.035 3.035-4.148 1.995-.092 3.362 1.055 4.57 2.39 1.557 1.72 2.984 3.558 4.514 5.305 2.202 2.515 4.797 4.134 8.347 3.634 3.183-.448 5.958-1.725 8.371-3.828.363-.316.761-.592 1.144-.886l-.241-.284c-2.027.63-4.093.841-6.205.735-3.195-.16-6.24-.828-8.964-2.582-2.486-1.601-4.319-3.746-5.19-6.611-.704-2.315.736-3.934 3.135-3.6.948.133 1.746.56 2.463 1.165.583.493 1.143 1.015 1.738 1.493 2.8 2.25 6.712 2.375 10.265-.068-5.842-.026-9.817-3.24-13.308-7.313-1.366-1.594-2.7-3.216-4.095-4.785-2.698-3.036-5.692-5.71-9.79-6.623C12.8-.623 7.745.14 2.893 2.361 1.926 2.804.997 3.319 0 4.149c.494 0 .763.006 1.032 0 2.446-.064 4.28 1.023 5.602 3.024.962 1.457 1.415 3.104 1.761 4.798.513 2.515.247 5.078.544 7.605.761 6.494 4.08 11.026 10.26 13.346 2.267.852 4.591 1.135 7.172.555ZM10.751 3.852c-.976.246-1.756-.148-2.56-.962 1.377-.343 2.592-.476 3.897-.528-.107.848-.607 1.306-1.336 1.49Zm32.002 37.924c-.085-.626-.62-.901-1.04-1.228-1.857-1.446-4.03-1.958-6.333-2-1.375-.026-2.735-.128-4.031-.61-.595-.22-1.26-.505-1.244-1.272.015-.78.693-1 1.31-1.184.505-.15 1.026-.247 1.6-.382-1.46-.936-2.886-1.065-4.787-.3-2.993 1.202-5.943 1.06-8.926-.017-1.684-.608-3.179-1.563-4.735-2.408l-.077.057c1.29 2.115 3.034 3.817 5.004 5.271 3.793 2.8 7.936 4.471 12.784 3.73A66.714 66.714 0 0 1 37 40.877c1.98-.16 3.866.398 5.753.899Zm-9.14-30.345c-.105-.076-.206-.266-.42-.069 1.745 2.36 3.985 4.098 6.683 5.193 4.354 1.767 8.773 2.07 13.293.51 3.51-1.21 6.033-.028 7.343 3.38.19-3.955-2.137-6.837-5.843-7.401-2.084-.318-4.01.373-5.962.94-5.434 1.575-10.485.798-15.094-2.553Zm27.085 15.425c.708.059 1.416.123 2.124.185-1.6-1.405-3.55-1.517-5.523-1.404-3.003.17-5.167 1.903-7.14 3.972-1.739 1.824-3.31 3.87-5.903 4.604.043.078.054.117.066.117.35.005.699.021 1.047.005 3.768-.17 7.317-.965 10.14-3.7.89-.86 1.685-1.817 2.544-2.71.716-.746 1.584-1.159 2.645-1.07Zm-8.753-4.67c-2.812.246-5.254 1.409-7.548 2.943-1.766 1.18-3.654 1.738-5.776 1.37-.374-.066-.75-.114-1.124-.17l-.013.156c.135.07.265.151.405.207.354.14.702.308 1.07.395 4.083.971 7.992.474 11.516-1.803 2.221-1.435 4.521-1.707 7.013-1.336.252.038.503.083.756.107.234.022.479.255.795.003-2.179-1.574-4.526-2.096-7.094-1.872Zm-10.049-9.544c1.475.051 2.943-.142 4.486-1.059-.452.04-.643.04-.827.076-2.126.424-4.033-.04-5.733-1.383-.623-.493-1.257-.974-1.889-1.457-2.503-1.914-5.374-2.555-8.514-2.5.05.154.054.26.108.315 3.417 3.455 7.371 5.836 12.369 6.008Zm24.727 17.731c-2.114-2.097-4.952-2.367-7.578-.537 1.738.078 3.043.632 4.101 1.728a13 13 0 0 0 1.182 1.106c1.6 1.29 4.311 1.352 5.896.155-1.861-.726-1.861-.726-3.601-2.452Zm-21.058 16.06c-1.858-3.46-4.981-4.24-8.59-4.008a9.667 9.667 0 0 1 2.977 1.39c.84.586 1.547 1.311 2.243 2.055 1.38 1.473 3.534 2.376 4.962 2.07-.656-.412-1.238-.848-1.592-1.507Zl-.006.006-.036-.004.021.018.012.053Za.127.127 0 0 0 .015.043c.005.008.038 0 .058-.002Zl-.008.01.005.026.024.014Z"
|
|
||||||
fill="#FD4F00"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 3.0 KiB |
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "Inner Square Chess",
|
||||||
|
"short_name": "Inner Square",
|
||||||
|
"start_url": "/",
|
||||||
|
"scope": "/",
|
||||||
|
"display": "standalone",
|
||||||
|
"background_color": "#f4f0e6",
|
||||||
|
"theme_color": "#17352d",
|
||||||
|
"icons": [
|
||||||
|
{ "src": "/android-chrome-192x192.png", "sizes": "192x192", "type": "image/png", "purpose": "any maskable" },
|
||||||
|
{ "src": "/android-chrome-512x512.png", "sizes": "512x512", "type": "image/png", "purpose": "any maskable" }
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -84,7 +84,10 @@ defmodule ChesstrainerWeb.EndgameLive.FormTest do
|
|||||||
|
|
||||||
assert html =~ "max-w-2xl"
|
assert html =~ "max-w-2xl"
|
||||||
|
|
||||||
view |> form("#theme-form", %{theme_search: "Luc"}) |> render_change()
|
view
|
||||||
|
|> element("#theme-picker input[name='theme_search']")
|
||||||
|
|> render_change(%{theme_search: "Luc"})
|
||||||
|
|
||||||
view |> element("button", "Lucena") |> render_click()
|
view |> element("button", "Lucena") |> render_click()
|
||||||
|
|
||||||
view
|
view
|
||||||
@@ -109,10 +112,16 @@ defmodule ChesstrainerWeb.EndgameLive.FormTest do
|
|||||||
|
|
||||||
{:ok, view, _html} = live(conn, ~p"/admin/endgames/new")
|
{:ok, view, _html} = live(conn, ~p"/admin/endgames/new")
|
||||||
|
|
||||||
view |> form("#theme-form", %{theme_search: "Luc"}) |> render_change()
|
view
|
||||||
|
|> element("#theme-picker input[name='theme_search']")
|
||||||
|
|> render_change(%{theme_search: "Luc"})
|
||||||
|
|
||||||
view |> element("button", "Lucena") |> render_click()
|
view |> element("button", "Lucena") |> render_click()
|
||||||
|
|
||||||
view |> form("#theme-form", %{theme_search: "Phil"}) |> render_change()
|
view
|
||||||
|
|> element("#theme-picker input[name='theme_search']")
|
||||||
|
|> render_change(%{theme_search: "Phil"})
|
||||||
|
|
||||||
view |> element("button", "Philidor") |> render_click()
|
view |> element("button", "Philidor") |> render_click()
|
||||||
|
|
||||||
html = render(view)
|
html = render(view)
|
||||||
@@ -123,7 +132,11 @@ defmodule ChesstrainerWeb.EndgameLive.FormTest do
|
|||||||
test "creates and attaches a new theme inline", %{conn: conn} do
|
test "creates and attaches a new theme inline", %{conn: conn} do
|
||||||
{:ok, view, _html} = live(conn, ~p"/admin/endgames/new")
|
{:ok, view, _html} = live(conn, ~p"/admin/endgames/new")
|
||||||
|
|
||||||
view |> form("#theme-form", %{theme_search: "Lucerne"}) |> render_submit()
|
view
|
||||||
|
|> element("#theme-picker input[name='theme_search']")
|
||||||
|
|> render_change(%{theme_search: "Lucerne"})
|
||||||
|
|
||||||
|
view |> element("button", ~s(Create theme "Lucerne")) |> render_click()
|
||||||
|
|
||||||
assert render(view) =~ "Lucerne"
|
assert render(view) =~ "Lucerne"
|
||||||
assert [%{name: "Lucerne"}] = Themes.search("Lucerne", "endgame")
|
assert [%{name: "Lucerne"}] = Themes.search("Lucerne", "endgame")
|
||||||
|
|||||||
@@ -35,7 +35,10 @@ defmodule ChesstrainerWeb.EndgameLive.ImportTest do
|
|||||||
assert html =~ "KR v K"
|
assert html =~ "KR v K"
|
||||||
assert html =~ "win"
|
assert html =~ "win"
|
||||||
|
|
||||||
view |> form("#theme-form", %{theme_search: "Luc"}) |> render_change()
|
view
|
||||||
|
|> element("#theme-picker input[name='theme_search']")
|
||||||
|
|> render_change(%{theme_search: "Luc"})
|
||||||
|
|
||||||
view |> element("button", "Lucena") |> render_click()
|
view |> element("button", "Lucena") |> render_click()
|
||||||
|
|
||||||
view |> element("button", "Import 1 endgame(s)") |> render_click()
|
view |> element("button", "Import 1 endgame(s)") |> render_click()
|
||||||
|
|||||||