Merge branch 'main' into check_upload_size
This commit is contained in:
@@ -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 <div className="landing-page">
|
||||
@@ -193,8 +178,8 @@ function LandingPage() {
|
||||
</p>
|
||||
</Trans>
|
||||
<p>
|
||||
{ usageMem >= 0 && <> {t("RAM")}: <strong>{usageMem} %</strong>{t(" used")}.<br/></> }
|
||||
{ usageCPU >= 0 && <> {t("CPU")}: <strong>{usageCPU} %</strong>{t(" used")}. </> }
|
||||
{ usageMem >= 0 && <> {t("RAM")}: <strong>{usageMem.toFixed(2)} %</strong>{t(" used")}.<br/></> }
|
||||
{ usageCPU >= 0 && <> {t("CPU")}: <strong>{usageCPU.toFixed(2)} %</strong>{t(" used")}. </> }
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
@@ -254,6 +239,31 @@ function LandingPage() {
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
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
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
"leanprover-community/nng4",
|
||||
"hhu-adam/robo",
|
||||
"djvelleman/stg4",
|
||||
"trequetrum/lean4game-logic"
|
||||
"trequetrum/lean4game-logic",
|
||||
"jadabouhawili/knightsandknaves-lean4game"
|
||||
],
|
||||
|
||||
"languages": [
|
||||
|
||||
+5
-1
@@ -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!
|
||||
|
||||
+4
-4
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user