fix(api): дождаться заданий планировщика перед операцией с БД

This commit is contained in:
Denozordec committed 2026-10-07 22:41:50 +07:00
1 parent 6720ad3539
commit 1b89d56ea3
13 files changed
+175 -12

No files matched your search

@@ -8,7 +8,7 @@ import { env } from "../config.js"
import { pool } from "../db/index.js"
import { withOperationLock } from "../db/operation-lock.js"
import { executeDatabaseOperation, type DatabaseOperationWarnings } from "./system-database-operation.js"
import { refreshScheduler, stopScheduler } from "./scheduler.js"
import { restartSchedulerAfterDatabaseOperation, stopSchedulerForDatabaseOperation } from "./scheduler.js"
import {
startTrafficFlowListener,
stopTrafficFlowListener,
@@ -49,9 +49,9 @@ function spawnCollected(command: string, args: string[], opts?: { stdin?: Buffer
async function withDatabaseOperation<T extends object>(fn: () => Promise<T>): Promise<T & DatabaseOperationWarnings> {
return withOperationLock(() => pool.connect(), BACKUP_LOCK_KEY, () => executeDatabaseOperation(fn, {
stopListener: stopTrafficFlowListener,
stopScheduler,
stopScheduler: stopSchedulerForDatabaseOperation,
startListener: startTrafficFlowListener,
startScheduler: refreshScheduler,
startScheduler: restartSchedulerAfterDatabaseOperation,
}), "Операция с базой приложения уже выполняется")
}