GIScience / OSM-realtime-update

:clock2: OpenStreetMap Data Extracts - updated on the fly!
https://giscience.github.io/OSM-realtime-update/
MIT License
41 stars 6 forks source link

Handle exit signals for clean shutdown #15

Closed sedot42 closed 6 years ago

sedot42 commented 6 years ago

Terminating the instance via Ctrl+C or killing the node process usually leaves a residue of temporary files. In order to have a clean shutdown, we should watch for process exit signals and handle them gracefully.

From the docs:

// Using a single function to handle multiple signals
function handle(signal) {
  console.log('Received signal.  Press Control-D to exit.');
  process.exit()
}

process.on('SIGINT', handle);
process.on('SIGTERM', handle);
process.on('SIGHUP', handle);
});