Deploy artifacts: Termux service scripts plus tunnel config
deploy/termux-{start,stop,status}.sh manage the release binary on the
tablet; deploy/cloudflared-whaleprep.yml is the dedicated tunnel config
for whaleprep.oiupoyt.space. README gains a deploy section.
This commit is contained in:
parent
ff1c23eaec
commit
c4080976bc
5 changed files with 75 additions and 0 deletions
18
README.md
18
README.md
|
|
@ -125,6 +125,24 @@ Recommended floor: **1 vCPU / 512 MB RAM / 5 GB disk**. Comfortable headroom:
|
|||
**1 vCPU / 1 GB RAM / 10 GB SSD**. No Postgres, no Redis, no object storage —
|
||||
one static binary plus one SQLite file.
|
||||
|
||||
## Deploy (Termux + Cloudflare Tunnel)
|
||||
|
||||
The live site runs on an ARM tablet via Termux behind a dedicated tunnel:
|
||||
|
||||
# on the host
|
||||
pkg install rust sqlite python git
|
||||
git clone https://git.oiupoyt.space/oiupoyt/whaleprep.git
|
||||
cd whaleprep && cargo build --release
|
||||
./deploy/termux-start.sh
|
||||
python3 scripts/import_examgoal.py whaleprep.db # 9,813 real PYQs
|
||||
|
||||
# tunnel (once): cloudflared tunnel create whaleprep, point the CNAME at it
|
||||
cloudflared tunnel --config ~/.cloudflared/whaleprep.yml \
|
||||
run ffc0df8c-0978-4b54-93a1-57c64fa1464c
|
||||
|
||||
See [deploy/](deploy/) for the service scripts and tunnel config.
|
||||
Live at: https://whaleprep.oiupoyt.space
|
||||
|
||||
## Tests
|
||||
|
||||
cargo test
|
||||
|
|
|
|||
14
deploy/cloudflared-whaleprep.yml
Normal file
14
deploy/cloudflared-whaleprep.yml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Dedicated tunnel config for whaleprep.oiupoyt.space.
|
||||
# On the Termux host this lives at ~/.cloudflared/whaleprep.yml with the
|
||||
# credentials-file path adjusted to that machine's home.
|
||||
# Create once: cloudflared tunnel create whaleprep
|
||||
# DNS once: cloudflared tunnel --config whaleprep.yml route dns --overwrite-dns <TUNNEL_ID> whaleprep.oiupoyt.space
|
||||
# Run: cloudflared tunnel --config whaleprep.yml run <TUNNEL_ID>
|
||||
tunnel: FFC0DF8C-0978-4B54-93A1-57C64FA1464C
|
||||
credentials-file: ~/.cloudflared/ffc0df8c-0978-4b54-93a1-57c64fa1464c.json
|
||||
protocol: http2
|
||||
|
||||
ingress:
|
||||
- hostname: whaleprep.oiupoyt.space
|
||||
service: http://localhost:8222
|
||||
- service: http_status:404
|
||||
29
deploy/termux-start.sh
Executable file
29
deploy/termux-start.sh
Executable file
|
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env bash
|
||||
# Start WhalePrep on Termux (SQLite, port 8222) in background.
|
||||
# Usage: ./deploy/termux-start.sh (run from repo root)
|
||||
cd "$(dirname "$0")/.."
|
||||
PID_FILE="./whaleprep.pid"
|
||||
LOG_FILE="./whaleprep.log"
|
||||
DB_FILE="./whaleprep.db"
|
||||
PORT=8222
|
||||
if [ -f "$PID_FILE" ]; then
|
||||
PID=$(cat "$PID_FILE")
|
||||
if kill -0 "$PID" 2>/dev/null; then
|
||||
echo "WhalePrep is already running (PID: $PID)"
|
||||
exit 0
|
||||
else
|
||||
rm -f "$PID_FILE"
|
||||
fi
|
||||
fi
|
||||
[ -x ./target/release/whaleprep ] || { echo "missing ./target/release/whaleprep — run: cargo build --release"; exit 1; }
|
||||
echo "Starting WhalePrep on :$PORT (db $DB_FILE)..."
|
||||
PYQ_DB="$DB_FILE" PYQ_ADDR="127.0.0.1:$PORT" RUST_LOG=info nohup ./target/release/whaleprep </dev/null >> "$LOG_FILE" 2>&1 &
|
||||
NEW_PID=$!
|
||||
echo $NEW_PID > "$PID_FILE"
|
||||
disown $NEW_PID 2>/dev/null || true
|
||||
sleep 2
|
||||
if kill -0 "$NEW_PID" 2>/dev/null; then
|
||||
echo "WhalePrep started (PID: $NEW_PID) -> http://localhost:$PORT"
|
||||
else
|
||||
echo "FAILED — tail $LOG_FILE:"; tail -5 "$LOG_FILE"
|
||||
fi
|
||||
10
deploy/termux-status.sh
Executable file
10
deploy/termux-status.sh
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env bash
|
||||
# WhalePrep status + health ping. Usage: ./deploy/termux-status.sh
|
||||
cd "$(dirname "$0")/.."
|
||||
if [ -f ./whaleprep.pid ] && kill -0 "$(cat ./whaleprep.pid)" 2>/dev/null; then
|
||||
PID=$(cat ./whaleprep.pid)
|
||||
echo "RUNNING (PID $PID, RSS $(( $(ps -o rss= -p $PID 2>/dev/null || echo 0) / 1024 )) MB)"
|
||||
curl -s -o /dev/null -w "health=%{http_code}\n" http://127.0.0.1:8222/ 2>&1 || echo "port not responding"
|
||||
else
|
||||
echo "NOT running"
|
||||
fi
|
||||
4
deploy/termux-stop.sh
Executable file
4
deploy/termux-stop.sh
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
# Stop WhalePrep. Usage: ./deploy/termux-stop.sh (run from repo root)
|
||||
cd "$(dirname "$0")/.."
|
||||
[ -f ./whaleprep.pid ] && PID=$(cat ./whaleprep.pid) && kill "$PID" 2>/dev/null && rm -f ./whaleprep.pid && echo "stopped $PID" || echo "not running"
|
||||
Loading…
Add table
Reference in a new issue