fix(api): подтвердить остановку NetFlow перед операцией с БД
This commit is contained in:
1 parent
1b89d56ea3
commit
f8da3e08a0
14 files changed
+192
-11
No files matched your search
@@ -10,8 +10,8 @@ import { withOperationLock } from "../db/operation-lock.js"
|
||||
import { executeDatabaseOperation, type DatabaseOperationWarnings } from "./system-database-operation.js"
|
||||
import { restartSchedulerAfterDatabaseOperation, stopSchedulerForDatabaseOperation } from "./scheduler.js"
|
||||
import {
|
||||
startTrafficFlowListener,
|
||||
stopTrafficFlowListener,
|
||||
restartTrafficFlowListenerAfterDatabaseOperation,
|
||||
stopTrafficFlowListenerForDatabaseOperation,
|
||||
} from "./traffic-flow-ingest.js"
|
||||
|
||||
const BACKUP_LOCK_KEY = 8_723_102
|
||||
@@ -48,9 +48,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,
|
||||
stopListener: stopTrafficFlowListenerForDatabaseOperation,
|
||||
stopScheduler: stopSchedulerForDatabaseOperation,
|
||||
startListener: startTrafficFlowListener,
|
||||
startListener: restartTrafficFlowListenerAfterDatabaseOperation,
|
||||
startScheduler: restartSchedulerAfterDatabaseOperation,
|
||||
}), "Операция с базой приложения уже выполняется")
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user