feat: harden cron execution recovery and expose scheduling diagnostics

Reconcile scheduled and system cron triggers, isolate concurrent executions and retain verifiable exit statistics across restarts. Add paged task history, log and script browsing, dashboard timing details and regression coverage.
This commit is contained in:
whyour committed 2026-11-17 01:01:57 +08:00
1 parent 3b6a873520
commit 8a9e70e90b
166 files changed
+18942 -1800

No files matched your search

+26
View File
@@ -1,5 +1,6 @@
import { Sequelize, Transaction } from 'sequelize';
import config from '../config/index';
import type { Database } from 'sqlite3';
import { join } from 'path';
export const sequelize = new Sequelize({
@@ -20,4 +21,29 @@ export const sequelize = new Sequelize({
transactionType: Transaction.TYPES.IMMEDIATE,
});
// In DELETE journal mode, EXTRA flushes the unlink that makes a transaction
// final. Sequelize opens a separate SQLite handle for each transaction.
const initialized = new WeakMap<Database, Promise<void>>();
sequelize.addHook('beforeQuery', async (_options, query) => {
const connection = query.connection as Database;
let ready = initialized.get(connection);
if (!ready) {
ready = new Promise<void>((resolve, reject) => {
connection.run('PRAGMA synchronous=EXTRA', error => error ? reject(error) : resolve());
}).catch(error => {
initialized.delete(connection);
throw error;
});
initialized.set(connection, ready);
}
await ready;
});
// SQLite transactions use dedicated file handles outside Sequelize 6's pool.
// Its default destroyConnection targets the pool on COMMIT/ROLLBACK errors,
// leaving the native writer open. The SQLite release path closes that handle.
sequelize.connectionManager.destroyConnection = async (connection) => {
sequelize.connectionManager.releaseConnection(connection);
};
export type ResponseType<T> = { code: number; data?: T; message?: string };