refactor: debounce writing to disk

This commit is contained in:
Carlos Valente
2026-02-01 18:20:22 +01:00
committed by Carlos Valente
parent e16ec3f388
commit 77779a4648
4 changed files with 65 additions and 21 deletions
+5 -1
View File
@@ -25,7 +25,7 @@ import { integrationRouter } from './api-integration/integration.router.js';
// Import adapters
import { socket } from './adapters/WebsocketAdapter.js';
import { getDataProvider } from './classes/data-provider/DataProvider.js';
import { getDataProvider, flushPendingWrites } from './classes/data-provider/DataProvider.js';
// Services
import { logger } from './classes/Logger.js';
@@ -266,6 +266,10 @@ export const startIntegrations = async () => {
export const shutdown = async (exitCode = 0) => {
consoleHighlight(`Ontime shutting down with code ${exitCode}`);
await flushPendingWrites().catch((_error) => {
/** nothing do to here */
});
// clear the restore file if it was a normal exit
// 0 means it was a SIGNAL
// 1 means crash -> keep the file