diff --git a/client/src/components/landing_page.tsx b/client/src/components/landing_page.tsx
index b69f50c..3d4a0c9 100644
--- a/client/src/components/landing_page.tsx
+++ b/client/src/components/landing_page.tsx
@@ -122,25 +122,10 @@ function LandingPage() {
/** Parse `games/stats.csv` if present and display server capacity. */
React.useEffect(() => {
- fetch(`${window.location.origin}/data/stats`)
- .then(response => {if (response.ok) {
- return response.text() } else {throw ""}})
- .then(data => {
- // Parse the CSV content
- const lines = data.split('\n');
- const [header, line2] = lines;
- if (!(header.replace(' ', '').startsWith("CPU,MEM"))) {
- console.info("Not displaying server stats: received unexpected: ", header)
- }
- if (line2) {
- let values = line2.split(',')
- setUsageCPU(100 * parseFloat(values[0]));
- setUsageMem(100 * parseFloat(values[1]));
- }
- }).catch(err => {
- console.info('server stats unavailable')
- console.debug(err)
- })
+ const interval = setInterval(() => {
+ fetch_stats();
+ }, 2000)
+ return () => clearInterval(interval)
}, [])
return
@@ -193,8 +178,8 @@ function LandingPage() {
- { usageMem >= 0 && <> {t("RAM")}: {usageMem} %{t(" used")}.
> }
- { usageCPU >= 0 && <> {t("CPU")}: {usageCPU} %{t(" used")}. > }
+ { usageMem >= 0 && <> {t("RAM")}: {usageMem.toFixed(2)} %{t(" used")}.
> }
+ { usageCPU >= 0 && <> {t("CPU")}: {usageCPU.toFixed(2)} %{t(" used")}. > }
@@ -254,6 +239,31 @@ function LandingPage() {
+
+ function fetch_stats() {
+ fetch(`${window.location.origin}/data/stats`)
+ .then(response => {
+ if (response.ok) {
+ return response.text();
+ } else { throw ""; }
+ })
+ .then(data => {
+ // Parse the CSV content
+ const lines = data.split('\n');
+ const [header, line2] = lines;
+ if (!(header.replace(' ', '').startsWith("CPU,MEM"))) {
+ console.info("Not displaying server stats: received unexpected: ", header);
+ }
+ if (line2) {
+ let values = line2.split(',');
+ setUsageCPU(100 * parseFloat(values[0]));
+ setUsageMem(100 * parseFloat(values[1]));
+ }
+ }).catch(err => {
+ console.info('server stats unavailable');
+ console.debug(err);
+ });
+ }
}
export default LandingPage
diff --git a/client/src/config.json b/client/src/config.json
index cc4261d..8ae10b0 100644
--- a/client/src/config.json
+++ b/client/src/config.json
@@ -3,7 +3,8 @@
"leanprover-community/nng4",
"hhu-adam/robo",
"djvelleman/stg4",
- "trequetrum/lean4game-logic"
+ "trequetrum/lean4game-logic",
+ "jadabouhawili/knightsandknaves-lean4game"
],
"languages": [
diff --git a/doc/publish_game.md b/doc/publish_game.md
index bd017fe..e720bf4 100644
--- a/doc/publish_game.md
+++ b/doc/publish_game.md
@@ -24,7 +24,11 @@ You should see a white screen which shows import updates and eventually reports
Now you can immediately play the game at `adam.math.hhu.de/#/g/{USER}/{REPOSITORY}`!
-## 4. Main page
+## 4. Update
+
+To upload a new version of the game you will have to repeat 1. and 2. whenever you want to publish the updated version.
+
+## 5. Main page
Adding games to the main page happens manually by the server maintainers. Tell us if you want us
to add a tile for your game!
diff --git a/relay/stats.sh b/relay/stats.sh
index 8996046..f51d270 100755
--- a/relay/stats.sh
+++ b/relay/stats.sh
@@ -3,10 +3,10 @@
# Load python interpreter
python=/usr/bin/python3
# Load python script
-cpu_usage=$L4G_DIR/lean4game/relay/cpu_usage.py
+cpu_usage=relay/cpu_usage.py
# Execute python script
cpu=$($python $cpu_usage)
-# Calculate memory usage by computing used_memory/total_memory
-mem=$(free | sed '2q;d' | awk '{print $3/$2}')
+# Calculate memory usage by computing 1 - %free_memory
+mem=$(free | sed '2q;d' | awk '{print 1 - ($4/$2)}')
-printf "CPU, MEM\n%.2f, %.2f\n" $cpu $mem
+printf "CPU, MEM\n%f, %f\n" $cpu $mem