Merge pull request 'SOGS QR Caching & backend improvements' (#17) from gravel/sessioncommunities.online:backend-caching into main
Reviewed-on: SomeGuy/sessioncommunities.online#17dev
commit
8af459e55c
@ -1,32 +1,71 @@
|
|||||||
# First goal is always run with just `make`
|
port = 8081
|
||||||
all:
|
output = output
|
||||||
/bin/php php/update-listing.php
|
|
||||||
|
|
||||||
data:
|
# First goal is the default with `make`.
|
||||||
|
|
||||||
|
# List make scripts.
|
||||||
|
list:
|
||||||
|
grep "^[^[:space:]]*:" Makefile --before-context=1 --group-separator=""
|
||||||
|
|
||||||
|
## Using make dependencies is duplicating behaviour but reads better.
|
||||||
|
# /bin/php php/update-listing.php
|
||||||
|
# Refresh listing and generate HTML.
|
||||||
|
all: fetch html
|
||||||
|
|
||||||
|
# Fetch room listing.
|
||||||
|
fetch:
|
||||||
/bin/php php/fetch-servers.php
|
/bin/php php/fetch-servers.php
|
||||||
|
|
||||||
|
# Generate HTML from data.
|
||||||
html:
|
html:
|
||||||
/bin/php php/generate-html.php
|
/bin/php php/generate-html.php
|
||||||
|
|
||||||
dev:
|
# Last item run in foreground to receive interrupts.
|
||||||
xdg-open http://localhost:8080
|
|
||||||
|
# Serve a local copy which responds to file changes.
|
||||||
|
dev: open
|
||||||
make server &
|
make server &
|
||||||
make watchdog
|
make watchdog
|
||||||
|
|
||||||
lan-dev:
|
# Serve a local copy on LAN which responds to file changes.
|
||||||
|
lan-dev: open
|
||||||
ip addr | fgrep -e ' 192.' -e ' 10.'
|
ip addr | fgrep -e ' 192.' -e ' 10.'
|
||||||
xdg-open http://localhost:8080
|
|
||||||
make lan-server &
|
make lan-server &
|
||||||
make watchdog
|
make watchdog
|
||||||
|
|
||||||
|
# Serve a local copy.
|
||||||
server:
|
server:
|
||||||
/bin/php -S localhost:8080 -t output
|
/bin/php -S localhost:$(port) -t $(output)
|
||||||
|
|
||||||
|
# Serve a local copy on all interfaces.
|
||||||
lan-server:
|
lan-server:
|
||||||
/bin/php -S 0.0.0.0:8080 -t output
|
/bin/php -S 0.0.0.0:$(port) -t $(output)
|
||||||
|
|
||||||
|
# Open locally served page in browser.
|
||||||
|
open:
|
||||||
|
xdg-open http://localhost:$(port) >/dev/null 2>/dev/null & disown
|
||||||
|
|
||||||
# Update html on file change
|
# Update HTML on file change. Doesn't check for new files.
|
||||||
# Doesn't check for new files
|
|
||||||
watchdog:
|
watchdog:
|
||||||
find . | entr -n -s "make html"
|
find . | entr -n -s "make html"
|
||||||
|
|
||||||
|
# Remove artefacts
|
||||||
|
clean:
|
||||||
|
rm -r cache
|
||||||
|
rm -r output/*.html
|
||||||
|
|
||||||
|
# Build everything from scratch and test functionality.
|
||||||
|
test: clean all open server
|
||||||
|
|
||||||
|
# Build everything from scratch and test functionality on LAN.
|
||||||
|
test-lan: clean all open lan-server
|
||||||
|
|
||||||
|
# -- Aliases --
|
||||||
|
serve: server
|
||||||
|
|
||||||
|
lan-serve: lan-server
|
||||||
|
|
||||||
|
data: fetch
|
||||||
|
|
||||||
|
watch: watchdog
|
||||||
|
|
||||||
|
@ -1,8 +1,3 @@
|
|||||||
Running, please wait...
|
|
||||||
This script will usually take approximately 4 minutes to run.
|
|
||||||
It will take longer if the Chinese servers are spasming out
|
|
||||||
or if you are running this for the first time.
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
require_once 'fetch-servers.php';
|
require_once 'fetch-servers.php';
|
||||||
require_once 'generate-html.php';
|
require_once 'generate-html.php';
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
$hrtime_start = hrtime();
|
||||||
|
$NANOSEC = 1E9;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate process runtime as [s, ns].
|
||||||
|
*/
|
||||||
|
function hrtime_interval() {
|
||||||
|
global $hrtime_start, $NANOSEC;
|
||||||
|
list($s, $ns) = hrtime();
|
||||||
|
list($s0, $ns0) = $hrtime_start;
|
||||||
|
// Borrow
|
||||||
|
if ($ns < $ns0) { $s--; $ns += $NANOSEC; }
|
||||||
|
return [$s - $s0, $ns - $ns0];
|
||||||
|
}
|
||||||
|
|
||||||
|
function runtime_str() {
|
||||||
|
list($s, $ns) = hrtime_interval();
|
||||||
|
return
|
||||||
|
date('i:s.', $s) .
|
||||||
|
str_pad(intdiv($ns, 1E6), 3, "0", STR_PAD_LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
function log_info($msg) {
|
||||||
|
fwrite(STDERR, "[" . runtime_str() . "] [i] $msg" . PHP_EOL);
|
||||||
|
}
|
||||||
|
?>
|
Loading…
Reference in New Issue