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,23 +170,29 @@ export default /*html*/ `
|
|||
}
|
||||
|
||||
async function refresh(){
|
||||
let resp = await fetch("json");
|
||||
if(resp.status != 200){
|
||||
pre.innerText = "Outbag Log Api is disabled<br>";
|
||||
return;
|
||||
try{
|
||||
let resp = await fetch("json");
|
||||
if(resp.status != 200){
|
||||
throw new Error("can not get Data");
|
||||
}
|
||||
let json = await resp.json();
|
||||
|
||||
let scrollPosition = document.documentElement.getBoundingClientRect().bottom;
|
||||
let heigth = window.innerHeight;
|
||||
|
||||
let scroll = heigth + 50 >= scrollPosition;
|
||||
if(loaded.length == 0) pre.innerText = "";
|
||||
json.forEach(d=>{
|
||||
if(loaded.includes(d[0])) return;
|
||||
loaded.push(d[0]);
|
||||
parse(d);
|
||||
});
|
||||
if(scroll) document.documentElement.scrollIntoView(false);
|
||||
}catch(_){
|
||||
pre.innerText = "Outbag Log Api is disabled or Server is down.";
|
||||
loaded = [];
|
||||
}
|
||||
let json = await resp.json();
|
||||
|
||||
let scrollPosition = document.documentElement.getBoundingClientRect().bottom;
|
||||
let heigth = window.innerHeight;
|
||||
|
||||
let scroll = heigth + 50 >= scrollPosition;
|
||||
json.forEach(d=>{
|
||||
if(loaded.includes(d[0])) return;
|
||||
loaded.push(d[0]);
|
||||
parse(d);
|
||||
});
|
||||
if(scroll) document.documentElement.scrollIntoView(false);
|
||||
}
|
||||
|
||||
setInterval(refresh, 1000);
|
||||
|
|
|
@ -64,11 +64,14 @@ program.parse();
|
|||
|
||||
const activeRequest = false;
|
||||
|
||||
var serverclose = { close: (d: () => void) => d() };
|
||||
var serverclose: (https.Server | http.Server | null) = null;
|
||||
nman.addShutdownTask(() => new Promise(async (res, rej) => {
|
||||
await closeWebSocket();
|
||||
serverclose.close(() => res());
|
||||
}), 30000);
|
||||
if (serverclose != null) {
|
||||
serverclose.keepAliveTimeout = 100;
|
||||
serverclose.close(() => res());
|
||||
}
|
||||
}), 10000);
|
||||
|
||||
async function startServer() {
|
||||
await connectToDB();
|
||||
|
|
Loading…
Reference in a new issue