mirror of
https://github.com/whyour/qinglong.git
synced 2026-12-01 01:39:52 +08:00
perf(cron): share global concurrency budget and streamline execution
Share durable permits across manual, scheduled and recovered runs, prioritize short ready tasks with aging, and record global queue occupancy. Reduce launch, log polling, dashboard and SQLite overhead while preserving transactional receipts, cancellation, recovery and script hook compatibility. Keep ordinary CRUD in ORM and bound SQL on measured execution hot paths. Fix supervisor descendant tracking, asynchronous log draining, concurrent log directory creation, Linux fallback launches and snapshot clock rollback. Include regression coverage, SQL audits and evolution/review documentation. Validation: five review rounds; local full suite 1478 passed, 28 platform skips; dev suites 415 passed, no failures/skips; backend types and formatting passed.
This commit is contained in:
1 parent
cddabbaf0e
commit
2f01f756d7
74 files changed
+6891
-837
No files matched your search
@@ -4,10 +4,25 @@ const path = require('path');
|
||||
const client = require('./client.js');
|
||||
require(`./env.js`);
|
||||
|
||||
// 注册 ESM loader,使全局安装的包也可通过 import 导入
|
||||
// Node 22.15+ can resolve ESM on the current thread, without a loader worker.
|
||||
// CommonJS keeps preferGlobalNodeModules and its panel-dependency isolation.
|
||||
try {
|
||||
Module.register(new URL('esm-loader.mjs', `file://${__dirname}/`).href);
|
||||
} catch (_) {}
|
||||
if (typeof Module.registerHooks !== 'function') {
|
||||
throw new Error('Synchronous module hooks unavailable');
|
||||
}
|
||||
const { resolve } = require('./esm-loader.mjs');
|
||||
Module.registerHooks({
|
||||
resolve(specifier, context, nextResolve) {
|
||||
return context.conditions.includes('require')
|
||||
? nextResolve(specifier, context)
|
||||
: resolve(specifier, context, nextResolve);
|
||||
},
|
||||
});
|
||||
} catch (_) {
|
||||
try {
|
||||
Module.register(new URL('esm-loader.mjs', `file://${__dirname}/`).href);
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
function preferGlobalNodeModules() {
|
||||
const { QL_NODE_GLOBAL_PATH } = process.env;
|
||||
@@ -78,14 +93,15 @@ function run() {
|
||||
`${dir_scripts}/`,
|
||||
'',
|
||||
);
|
||||
const tempFile = `/tmp/env_${process.pid}.json`;
|
||||
const tempFile = `/tmp/env_${process.pid}.data`;
|
||||
|
||||
// Pass paths as arguments: shell syntax in a filename must stay literal.
|
||||
const command = `file="$1"; output="$2"; inline="$3"; shift 3
|
||||
source "$file" "$@" &&
|
||||
{ if [ -n "$inline" ]; then eval "$inline"; fi; } &&
|
||||
printf '%s\\n' '__sitecustomize__' &&
|
||||
node -e 'require("fs").writeFileSync(process.argv[1], JSON.stringify(process.env))' "$output"`;
|
||||
{ command env -0 > "$output" 2>/dev/null ||
|
||||
node -e 'require("fs").writeFileSync(process.argv[1], JSON.stringify(process.env))' "$output"; }`;
|
||||
|
||||
if (task_before) {
|
||||
console.log(
|
||||
@@ -113,7 +129,19 @@ node -e 'require("fs").writeFileSync(process.argv[1], JSON.stringify(process.env
|
||||
|
||||
try {
|
||||
const envStr = require('fs').readFileSync(tempFile, 'utf-8');
|
||||
const newEnvObject = JSON.parse(envStr);
|
||||
// NUL separates environment entries without escaping Unicode, newlines
|
||||
// or '=' in values. Keep JSON for env implementations without -0.
|
||||
const newEnvObject = envStr.includes('\0')
|
||||
? Object.fromEntries(
|
||||
envStr
|
||||
.split('\0')
|
||||
.filter(Boolean)
|
||||
.map((entry) => {
|
||||
const separator = entry.indexOf('=');
|
||||
return [entry.slice(0, separator), entry.slice(separator + 1)];
|
||||
}),
|
||||
)
|
||||
: JSON.parse(envStr);
|
||||
if (typeof newEnvObject === 'object' && newEnvObject !== null) {
|
||||
for (const key in newEnvObject) {
|
||||
if (
|
||||
|
||||
Reference in new issue
Block a user