fix: address code review feedback - reset editor timer, fix graceful shutdown timeout
Agent-Logs-Url: https://github.com/qinfendebingshuo/guanghulab/sessions/283b1454-583c-4cf7-8df8-444f15863b52 Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com>
This commit is contained in:
parent
e2669f05b0
commit
5fed40c4f3
|
|
@ -1944,14 +1944,14 @@ document.getElementById('edNewCh').onclick=function(){
|
||||||
var editorStartTime=null;
|
var editorStartTime=null;
|
||||||
var editorTimerInterval=null;
|
var editorTimerInterval=null;
|
||||||
function startEditorTimer(){
|
function startEditorTimer(){
|
||||||
if(editorTimerInterval)return;
|
stopEditorTimer();
|
||||||
editorStartTime=Date.now();
|
editorStartTime=Date.now();
|
||||||
editorTimerInterval=setInterval(function(){
|
editorTimerInterval=setInterval(function(){
|
||||||
var el=document.getElementById('edTimer');
|
var el=document.getElementById('edTimer');
|
||||||
if(!el)return;
|
if(!el)return;
|
||||||
var elapsed=Math.floor((Date.now()-editorStartTime)/60000);
|
var elapsed=Math.floor((Date.now()-editorStartTime)/60000);
|
||||||
el.textContent='⏱ '+elapsed+'min';
|
el.textContent='⏱ '+elapsed+'min';
|
||||||
},10000);
|
},60000);
|
||||||
}
|
}
|
||||||
function stopEditorTimer(){
|
function stopEditorTimer(){
|
||||||
if(editorTimerInterval){clearInterval(editorTimerInterval);editorTimerInterval=null}
|
if(editorTimerInterval){clearInterval(editorTimerInterval);editorTimerInterval=null}
|
||||||
|
|
|
||||||
|
|
@ -570,11 +570,12 @@ server.listen(PORT, '127.0.0.1', () => {
|
||||||
// Graceful shutdown
|
// Graceful shutdown
|
||||||
function gracefulShutdown(signal) {
|
function gracefulShutdown(signal) {
|
||||||
console.log(`\n${signal} received. Shutting down gracefully...`);
|
console.log(`\n${signal} received. Shutting down gracefully...`);
|
||||||
|
const forceExit = setTimeout(() => { process.exit(1); }, 5000);
|
||||||
server.close(() => {
|
server.close(() => {
|
||||||
|
clearTimeout(forceExit);
|
||||||
console.log('Server closed.');
|
console.log('Server closed.');
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
});
|
||||||
setTimeout(() => { process.exit(1); }, 5000);
|
|
||||||
}
|
}
|
||||||
process.on('SIGTERM', () => gracefulShutdown('SIGTERM'));
|
process.on('SIGTERM', () => gracefulShutdown('SIGTERM'));
|
||||||
process.on('SIGINT', () => gracefulShutdown('SIGINT'));
|
process.on('SIGINT', () => gracefulShutdown('SIGINT'));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue