fix, close keep-alive connections on shutdown
This commit is contained in:
parent
4a05383b70
commit
4856d477e4
2 changed files with 28 additions and 19 deletions
|
@ -170,10 +170,10 @@ export default /*html*/ `
|
||||||
}
|
}
|
||||||
|
|
||||||
async function refresh(){
|
async function refresh(){
|
||||||
|
try{
|
||||||
let resp = await fetch("json");
|
let resp = await fetch("json");
|
||||||
if(resp.status != 200){
|
if(resp.status != 200){
|
||||||
pre.innerText = "Outbag Log Api is disabled<br>";
|
throw new Error("can not get Data");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
let json = await resp.json();
|
let json = await resp.json();
|
||||||
|
|
||||||
|
@ -181,12 +181,18 @@ export default /*html*/ `
|
||||||
let heigth = window.innerHeight;
|
let heigth = window.innerHeight;
|
||||||
|
|
||||||
let scroll = heigth + 50 >= scrollPosition;
|
let scroll = heigth + 50 >= scrollPosition;
|
||||||
|
if(loaded.length == 0) pre.innerText = "";
|
||||||
json.forEach(d=>{
|
json.forEach(d=>{
|
||||||
if(loaded.includes(d[0])) return;
|
if(loaded.includes(d[0])) return;
|
||||||
loaded.push(d[0]);
|
loaded.push(d[0]);
|
||||||
parse(d);
|
parse(d);
|
||||||
});
|
});
|
||||||
if(scroll) document.documentElement.scrollIntoView(false);
|
if(scroll) document.documentElement.scrollIntoView(false);
|
||||||
|
}catch(_){
|
||||||
|
pre.innerText = "Outbag Log Api is disabled or Server is down.";
|
||||||
|
loaded = [];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setInterval(refresh, 1000);
|
setInterval(refresh, 1000);
|
||||||
|
|
|
@ -64,11 +64,14 @@ program.parse();
|
||||||
|
|
||||||
const activeRequest = false;
|
const activeRequest = false;
|
||||||
|
|
||||||
var serverclose = { close: (d: () => void) => d() };
|
var serverclose: (https.Server | http.Server | null) = null;
|
||||||
nman.addShutdownTask(() => new Promise(async (res, rej) => {
|
nman.addShutdownTask(() => new Promise(async (res, rej) => {
|
||||||
await closeWebSocket();
|
await closeWebSocket();
|
||||||
|
if (serverclose != null) {
|
||||||
|
serverclose.keepAliveTimeout = 100;
|
||||||
serverclose.close(() => res());
|
serverclose.close(() => res());
|
||||||
}), 30000);
|
}
|
||||||
|
}), 10000);
|
||||||
|
|
||||||
async function startServer() {
|
async function startServer() {
|
||||||
await connectToDB();
|
await connectToDB();
|
||||||
|
|
Loading…
Reference in a new issue