mirror of
https://github.com/whyour/qinglong.git
synced 2026-11-17 15:51:07 +08:00
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.
27 lines
1.1 KiB
JavaScript
27 lines
1.1 KiB
JavaScript
// Observe the first executable location in the entry file. Preloads, the TS
|
|
// compiler and ESM dependency evaluation can all run before that location.
|
|
const { Session, url } = require('inspector');
|
|
const { pathToFileURL } = require('url');
|
|
const { writeFileSync } = require('fs');
|
|
|
|
module.exports = function observeScriptStart(entry, marker) {
|
|
if (!entry || !marker || url()) return;
|
|
const session = new Session();
|
|
try {
|
|
session.connect();
|
|
const target = pathToFileURL(entry).href;
|
|
session.post('Debugger.enable');
|
|
session.post('Debugger.setBreakpointByUrl', { url: target, lineNumber: 0 }, (err, bp) => {
|
|
if (err || !bp) { session.disconnect(); return; }
|
|
session.on('Debugger.paused', ({ params }) => {
|
|
if (params.hitBreakpoints?.includes(bp.breakpointId)) {
|
|
try { writeFileSync(marker, String(Date.now()), { flag: 'wx', mode: 0o600 }); } catch {}
|
|
session.disconnect();
|
|
} else {
|
|
session.post('Debugger.resume');
|
|
}
|
|
});
|
|
});
|
|
} catch { try { session.disconnect(); } catch {} }
|
|
};
|