hastic-zzz / hastic-server

Hastic data management server for analyzing patterns and anomalies from Grafana
GNU General Public License v3.0
330 stars 23 forks source link

correct error handling in exitHandler #853

Closed jonyrock-back closed 4 years ago

jonyrock-back commented 4 years ago

this is how PrcessService.exitHandler looks like:

function exitHandler(options: any, err?: any) {
  if(exitHandled) {
    return;
  }
  exitHandled = true;
  for(let i = 0; i < exitHandlers.length; i++) {
    exitHandlers[i]();
  }
  console.log('process exit');
  process.exit();
}

the problem here is that if any of handlers throw an exception, then all other will not be executed. It should be much more robust if we catch exceptions and log about that

rozetko commented 4 years ago

closed via https://github.com/hastic/hastic-server/commit/09788eb0dd891647a08c884aaab9c30b9f549c07