@cloudnux/local-cloud-provider 0.6.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev-console-plugin/index.d.ts +0 -2
- package/dist/dev-console-plugin/index.js +82 -52
- package/dist/dev-console-plugin/index.js.map +1 -1
- package/dist/index.js +38 -1
- package/dist/index.js.map +1 -1
- package/dist/queue-plugin/index.d.ts +1 -2
- package/dist/queue-plugin/index.js +38 -17
- package/dist/queue-plugin/index.js.map +1 -1
- package/dist/schedule-plugin/index.d.ts +3 -1
- package/dist/schedule-plugin/index.js +44 -35
- package/dist/schedule-plugin/index.js.map +1 -1
- package/dist/websocket-plugin/index.d.ts +43 -0
- package/dist/websocket-plugin/index.js +96 -0
- package/dist/websocket-plugin/index.js.map +1 -0
- package/package.json +9 -2
|
@@ -20,7 +20,6 @@ interface QueueService {
|
|
|
20
20
|
dlq: QueueMessage[];
|
|
21
21
|
timeoutId: NodeJS.Timeout | null;
|
|
22
22
|
processingBatch: boolean;
|
|
23
|
-
activeProcessing: number;
|
|
24
23
|
module?: string;
|
|
25
24
|
}
|
|
26
25
|
interface QueueConfig {
|
|
@@ -43,7 +42,6 @@ interface QueueSummary {
|
|
|
43
42
|
processing: number;
|
|
44
43
|
dlq: number;
|
|
45
44
|
isProcessing: boolean;
|
|
46
|
-
activeProcessing: number;
|
|
47
45
|
configuration: {
|
|
48
46
|
batchSize: number;
|
|
49
47
|
batchWindowMs: number;
|
|
@@ -962,7 +962,6 @@ var createQueueService = (handler, module) => ({
|
|
|
962
962
|
dlq: [],
|
|
963
963
|
timeoutId: null,
|
|
964
964
|
processingBatch: false,
|
|
965
|
-
activeProcessing: 0,
|
|
966
965
|
module
|
|
967
966
|
});
|
|
968
967
|
var createQueueMessage = (body, headers) => {
|
|
@@ -1009,7 +1008,6 @@ var createQueueSummary = (queueService, config) => ({
|
|
|
1009
1008
|
processing: queueService.processing.length,
|
|
1010
1009
|
dlq: queueService.dlq.length,
|
|
1011
1010
|
isProcessing: queueService.processingBatch,
|
|
1012
|
-
activeProcessing: queueService.activeProcessing,
|
|
1013
1011
|
configuration: {
|
|
1014
1012
|
batchSize: config.batchSize,
|
|
1015
1013
|
batchWindowMs: config.batchWindowMs,
|
|
@@ -1051,7 +1049,7 @@ var logError = (message, messageId, queueName, error) => {
|
|
|
1051
1049
|
logger.error(`${logSymbols.error} ${chalk2.red(message)} ${chalk2.yellow(messageId)} in queue ${chalk2.magenta(queueName)}: ${error}`);
|
|
1052
1050
|
};
|
|
1053
1051
|
var logRetryScheduled = (messageId, delayMs) => {
|
|
1054
|
-
logger.
|
|
1052
|
+
logger.debug(`${chalk2.blue("\u23F1\uFE0F Scheduling retry")} for message ${chalk2.yellow(messageId)} in ${chalk2.cyan(delayMs)}ms`);
|
|
1055
1053
|
};
|
|
1056
1054
|
var logDLQOperation = (operation, count, queueName) => {
|
|
1057
1055
|
logger.warn(`${logSymbols.warning} ${chalk2.yellow(operation)} ${chalk2.red(count)} messages from DLQ for ${chalk2.green(queueName)}`);
|
|
@@ -1084,7 +1082,7 @@ var handleProcessingError = async (queueName, message, queueService, error, conf
|
|
|
1084
1082
|
}, delayMs);
|
|
1085
1083
|
}
|
|
1086
1084
|
};
|
|
1087
|
-
var createBatchProcessor = (processMessage, config,
|
|
1085
|
+
var createBatchProcessor = (processMessage, config, dirtyQueues) => async (queueName, queueService) => {
|
|
1088
1086
|
if (queueService.timeoutId) {
|
|
1089
1087
|
clearTimeout(queueService.timeoutId);
|
|
1090
1088
|
queueService.timeoutId = null;
|
|
@@ -1102,8 +1100,8 @@ var createBatchProcessor = (processMessage, config, saveQueueState) => async (qu
|
|
|
1102
1100
|
await Promise.all(messagesToProcess.map((message) => {
|
|
1103
1101
|
return processMessage(queueName, message, queueService);
|
|
1104
1102
|
}));
|
|
1105
|
-
if (config.persistence.enabled &&
|
|
1106
|
-
|
|
1103
|
+
if (config.persistence.enabled && dirtyQueues) {
|
|
1104
|
+
dirtyQueues.add(queueName);
|
|
1107
1105
|
}
|
|
1108
1106
|
} finally {
|
|
1109
1107
|
queueService.processingBatch = false;
|
|
@@ -1145,18 +1143,21 @@ var restoreDates = (messages) => {
|
|
|
1145
1143
|
if (msg.failedAt) msg.failedAt = new Date(msg.failedAt);
|
|
1146
1144
|
});
|
|
1147
1145
|
};
|
|
1148
|
-
var createPersistenceInitializer = (config, loadAllQueueStates, saveAllQueueStates) => async () => {
|
|
1146
|
+
var createPersistenceInitializer = (config, loadAllQueueStates, saveDirtyQueueStates, saveAllQueueStates, intervalIdHolder) => async () => {
|
|
1149
1147
|
try {
|
|
1150
1148
|
await fs.mkdir(config.persistence.directory, { recursive: true });
|
|
1151
1149
|
if (config.persistence.loadOnStartup) {
|
|
1152
1150
|
await loadAllQueueStates();
|
|
1153
1151
|
}
|
|
1154
1152
|
if (config.persistence.saveInterval > 0) {
|
|
1155
|
-
setInterval(
|
|
1153
|
+
intervalIdHolder.id = setInterval(saveDirtyQueueStates, config.persistence.saveInterval);
|
|
1156
1154
|
}
|
|
1157
1155
|
if (config.persistence.saveOnShutdown) {
|
|
1158
1156
|
const shutdownHandler = async () => {
|
|
1159
1157
|
logger.debug("Saving queue state before shutdown...");
|
|
1158
|
+
if (intervalIdHolder.id) {
|
|
1159
|
+
clearInterval(intervalIdHolder.id);
|
|
1160
|
+
}
|
|
1160
1161
|
await saveAllQueueStates();
|
|
1161
1162
|
process.exit(0);
|
|
1162
1163
|
};
|
|
@@ -1177,7 +1178,7 @@ var createQueueStateSaver = (config) => async (queueName, queueService) => {
|
|
|
1177
1178
|
const tempFilePath = path2.join(config.persistence.directory, `${queueName}.${now}temp.json`);
|
|
1178
1179
|
await fs.writeFile(tempFilePath, JSON.stringify(queueData, null, 2), "utf8");
|
|
1179
1180
|
await fs.rename(tempFilePath, queueFilePath);
|
|
1180
|
-
logger.
|
|
1181
|
+
logger.debug(`${logSymbols2.info} ${chalk3.blue("Queue state saved:")} ${chalk3.green(queueName)}`);
|
|
1181
1182
|
} catch (error) {
|
|
1182
1183
|
logger.error(`Failed to save queue state for ${queueName}:`, error);
|
|
1183
1184
|
}
|
|
@@ -1192,6 +1193,20 @@ var createAllQueuesStateSaver = (config, saveQueueState) => (queues) => async ()
|
|
|
1192
1193
|
logger.error(`${logSymbols2.error} ${chalk3.red("Failed to save all queue states:")} ${chalk3.yellow(error.message)}`);
|
|
1193
1194
|
}
|
|
1194
1195
|
};
|
|
1196
|
+
var createDirtyQueuesStateSaver = (saveQueueState, dirtyQueues) => (queues) => async () => {
|
|
1197
|
+
if (dirtyQueues.size === 0) return;
|
|
1198
|
+
try {
|
|
1199
|
+
const queueNames = [...dirtyQueues];
|
|
1200
|
+
dirtyQueues.clear();
|
|
1201
|
+
for (const queueName of queueNames) {
|
|
1202
|
+
if (queues[queueName]) {
|
|
1203
|
+
await saveQueueState(queueName, queues[queueName]);
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
} catch (error) {
|
|
1207
|
+
logger.error(`${logSymbols2.error} ${chalk3.red("Failed to save dirty queue states:")} ${chalk3.yellow(error.message)}`);
|
|
1208
|
+
}
|
|
1209
|
+
};
|
|
1195
1210
|
var createQueueStateLoader = (config, scheduleProcessing, processMessage) => (queues) => async (queueName) => {
|
|
1196
1211
|
try {
|
|
1197
1212
|
if (!queues[queueName]) {
|
|
@@ -1309,6 +1324,7 @@ var isValidQueueName = (queueName) => {
|
|
|
1309
1324
|
var createQueueManager = ({
|
|
1310
1325
|
config,
|
|
1311
1326
|
queues,
|
|
1327
|
+
dirtyQueues,
|
|
1312
1328
|
saveQueueState,
|
|
1313
1329
|
loadQueueState,
|
|
1314
1330
|
scheduleProcessing,
|
|
@@ -1419,8 +1435,8 @@ var createQueueManager = ({
|
|
|
1419
1435
|
queues[queueName].incoming.push(message);
|
|
1420
1436
|
scheduleProcessing(queueName, queues[queueName]);
|
|
1421
1437
|
handleImmediateProcessing(queues[queueName], config, processBatch, queueName);
|
|
1422
|
-
if (config.persistence.enabled
|
|
1423
|
-
|
|
1438
|
+
if (config.persistence.enabled) {
|
|
1439
|
+
dirtyQueues.add(queueName);
|
|
1424
1440
|
}
|
|
1425
1441
|
return {
|
|
1426
1442
|
id: message.id,
|
|
@@ -1441,8 +1457,8 @@ var createQueueManager = ({
|
|
|
1441
1457
|
}
|
|
1442
1458
|
logDLQOperation("Moving", processedCount, queueName);
|
|
1443
1459
|
scheduleProcessing(queueName, queues[queueName]);
|
|
1444
|
-
if (
|
|
1445
|
-
|
|
1460
|
+
if (config.persistence.enabled) {
|
|
1461
|
+
dirtyQueues.add(queueName);
|
|
1446
1462
|
}
|
|
1447
1463
|
return {
|
|
1448
1464
|
status: "success",
|
|
@@ -1463,8 +1479,8 @@ var createQueueManager = ({
|
|
|
1463
1479
|
};
|
|
1464
1480
|
}
|
|
1465
1481
|
logDLQOperation("Purging", purgedCount, queueName);
|
|
1466
|
-
if (
|
|
1467
|
-
|
|
1482
|
+
if (config.persistence.enabled) {
|
|
1483
|
+
dirtyQueues.add(queueName);
|
|
1468
1484
|
}
|
|
1469
1485
|
return {
|
|
1470
1486
|
status: "success",
|
|
@@ -1495,14 +1511,18 @@ var createQueueDecorator = (queueManager) => (app) => {
|
|
|
1495
1511
|
var queuesPlugin = fsPlugin(async (app, options) => {
|
|
1496
1512
|
const config = mergeConfig(DEFAULT_CONFIG, options.config);
|
|
1497
1513
|
const queues = {};
|
|
1514
|
+
const dirtyQueues = /* @__PURE__ */ new Set();
|
|
1515
|
+
const intervalIdHolder = {};
|
|
1498
1516
|
const processMessage = createProcessMessageHandler(config);
|
|
1499
1517
|
const saveQueueState = config.persistence.enabled ? createQueueStateSaver(config) : void 0;
|
|
1500
1518
|
const saveAllQueueStates = config.persistence.enabled && saveQueueState ? createAllQueuesStateSaver(config, saveQueueState)(queues) : async () => {
|
|
1501
1519
|
};
|
|
1520
|
+
const saveDirtyQueueStates = config.persistence.enabled && saveQueueState ? createDirtyQueuesStateSaver(saveQueueState, dirtyQueues)(queues) : async () => {
|
|
1521
|
+
};
|
|
1502
1522
|
const processBatch = createBatchProcessor(
|
|
1503
1523
|
processMessage,
|
|
1504
1524
|
config,
|
|
1505
|
-
|
|
1525
|
+
config.persistence.enabled ? dirtyQueues : void 0
|
|
1506
1526
|
);
|
|
1507
1527
|
const scheduleProcessing = createProcessingScheduler(processBatch, config);
|
|
1508
1528
|
const loadQueueState = config.persistence.enabled ? createQueueStateLoader(
|
|
@@ -1513,11 +1533,12 @@ var queuesPlugin = fsPlugin(async (app, options) => {
|
|
|
1513
1533
|
};
|
|
1514
1534
|
const loadAllQueueStates = config.persistence.enabled ? createAllQueuesStateLoader(config, loadQueueState) : async () => {
|
|
1515
1535
|
};
|
|
1516
|
-
const initializePersistence = config.persistence.enabled ? createPersistenceInitializer(config, loadAllQueueStates, saveAllQueueStates) : async () => {
|
|
1536
|
+
const initializePersistence = config.persistence.enabled ? createPersistenceInitializer(config, loadAllQueueStates, saveDirtyQueueStates, saveAllQueueStates, intervalIdHolder) : async () => {
|
|
1517
1537
|
};
|
|
1518
1538
|
const queueManager = createQueueManager({
|
|
1519
1539
|
config,
|
|
1520
1540
|
queues,
|
|
1541
|
+
dirtyQueues,
|
|
1521
1542
|
saveQueueState: saveQueueState ? (queueName) => saveQueueState(queueName, queues[queueName]) : void 0,
|
|
1522
1543
|
loadQueueState,
|
|
1523
1544
|
scheduleProcessing,
|
|
@@ -1921,17 +1942,22 @@ var scheduleJob = (scheduler, state, executeJobFn) => {
|
|
|
1921
1942
|
updatedScheduler.timerId = setTimeout(() => {
|
|
1922
1943
|
executeJobFn(updatedScheduler);
|
|
1923
1944
|
}, timeUntilNextRun);
|
|
1924
|
-
logger.
|
|
1945
|
+
logger.debug(`${chalk6.blue("\u{1F4C5} Scheduled job")} ${chalk6.green(scheduler.job.name)} to run in ${chalk6.cyan(Math.round(timeUntilNextRun / 1e3))}s`);
|
|
1925
1946
|
}
|
|
1926
1947
|
return updatedScheduler;
|
|
1927
1948
|
};
|
|
1928
1949
|
var executeJobWithTimeout = async (handler, job, execution, timeoutMs) => {
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
(
|
|
1933
|
-
|
|
1934
|
-
|
|
1950
|
+
let timerId;
|
|
1951
|
+
try {
|
|
1952
|
+
return await Promise.race([
|
|
1953
|
+
handler(job, execution),
|
|
1954
|
+
new Promise((_, reject) => {
|
|
1955
|
+
timerId = setTimeout(() => reject(new Error("Job execution timeout")), timeoutMs);
|
|
1956
|
+
})
|
|
1957
|
+
]);
|
|
1958
|
+
} finally {
|
|
1959
|
+
clearTimeout(timerId);
|
|
1960
|
+
}
|
|
1935
1961
|
};
|
|
1936
1962
|
var updateJobAfterExecution = (job, execution, config) => {
|
|
1937
1963
|
const updatedJob = {
|
|
@@ -1974,7 +2000,7 @@ var saveSchedulerState = async (state) => {
|
|
|
1974
2000
|
const tempFile = createTempFilePath(state.config.persistence.directory);
|
|
1975
2001
|
await fs2.writeFile(tempFile, JSON.stringify(serializedState, null, 2), "utf8");
|
|
1976
2002
|
await fs2.rename(tempFile, stateFile);
|
|
1977
|
-
logger.
|
|
2003
|
+
logger.debug(`${logSymbols5.info} ${chalk7.blue("Enhanced scheduler state saved")}`);
|
|
1978
2004
|
} catch (error) {
|
|
1979
2005
|
logger.error("Failed to save scheduler state:", error);
|
|
1980
2006
|
}
|
|
@@ -1986,7 +2012,7 @@ var loadSchedulerStateData = async (directory) => {
|
|
|
1986
2012
|
return JSON.parse(data);
|
|
1987
2013
|
} catch (error) {
|
|
1988
2014
|
if (error.code === "ENOENT") {
|
|
1989
|
-
logger.
|
|
2015
|
+
logger.debug(`${chalk7.blue("No previous scheduler state found - starting fresh")}`);
|
|
1990
2016
|
} else {
|
|
1991
2017
|
logger.error("Failed to load scheduler state:", error);
|
|
1992
2018
|
}
|
|
@@ -1999,20 +2025,20 @@ var validateAndAdjustNextRun = (job, savedNextRun, lastRestartTime, config) => {
|
|
|
1999
2025
|
return calculateNextRunFromLastRun(job, job.lastRun, config);
|
|
2000
2026
|
}
|
|
2001
2027
|
if (savedNextRun <= now) {
|
|
2002
|
-
logger.
|
|
2028
|
+
logger.debug(`${chalk7.yellow("\u23F0 Saved next run is in the past for")} ${chalk7.green(job.name)} - recalculating`);
|
|
2003
2029
|
return calculateNextRunFromLastRun(job, job.lastRun, config);
|
|
2004
2030
|
}
|
|
2005
2031
|
const timeSinceRestart = now.getTime() - lastRestartTime.getTime();
|
|
2006
2032
|
const isRapidRestart = timeSinceRestart < config.restartBehavior.rapidRestartThreshold;
|
|
2007
2033
|
if (isRapidRestart) {
|
|
2008
|
-
logger.
|
|
2034
|
+
logger.debug(`${chalk7.blue("\u26A1 Rapid restart detected for")} ${chalk7.green(job.name)} - preserving saved timing`);
|
|
2009
2035
|
return savedNextRun;
|
|
2010
2036
|
}
|
|
2011
2037
|
if (job.cronExpression || job.intervalMs) {
|
|
2012
2038
|
const expectedNextRun = calculateNextRunFromLastRun(job, job.lastRun, config);
|
|
2013
2039
|
const timeDiff = Math.abs(savedNextRun.getTime() - expectedNextRun.getTime());
|
|
2014
2040
|
if (timeDiff > config.restartBehavior.maxTimingDrift) {
|
|
2015
|
-
logger.
|
|
2041
|
+
logger.debug(`${chalk7.yellow("\u{1F527} Adjusting timing for")} ${chalk7.green(job.name)} - drift of ${Math.round(timeDiff / 1e3)}s detected`);
|
|
2016
2042
|
return expectedNextRun;
|
|
2017
2043
|
}
|
|
2018
2044
|
}
|
|
@@ -2026,7 +2052,7 @@ var restoreJobFromSavedData = (scheduler, savedJob, config, lastRestartTime) =>
|
|
|
2026
2052
|
lastRun: savedJob.lastRun ? new Date(savedJob.lastRun) : void 0
|
|
2027
2053
|
};
|
|
2028
2054
|
if (definitionChanged) {
|
|
2029
|
-
logger.
|
|
2055
|
+
logger.debug(`${chalk7.yellow("\u{1F504} Job definition changed:")} ${chalk7.green(savedJob.name)} - recalculating schedule`);
|
|
2030
2056
|
updatedJob.nextRun = calculateNextRunFromLastRun(updatedJob, updatedJob.lastRun, config);
|
|
2031
2057
|
} else {
|
|
2032
2058
|
const savedNextRun = savedJob.nextRun ? new Date(savedJob.nextRun) : void 0;
|
|
@@ -2036,7 +2062,7 @@ var restoreJobFromSavedData = (scheduler, savedJob, config, lastRestartTime) =>
|
|
|
2036
2062
|
const result = parseCronExpression(updatedJob.cronExpression, updatedJob.lastRun, {
|
|
2037
2063
|
timezone: updatedJob.timezone
|
|
2038
2064
|
});
|
|
2039
|
-
logger.
|
|
2065
|
+
logger.debug(`${chalk7.blue("\u{1F4C5} Job restored:")} ${chalk7.green(savedJob.name)} - ${result.description} - next: ${chalk7.cyan(updatedJob.nextRun.toLocaleString())}`);
|
|
2040
2066
|
}
|
|
2041
2067
|
return { ...scheduler, job: updatedJob };
|
|
2042
2068
|
};
|
|
@@ -2079,16 +2105,11 @@ var cleanupExecutionHistory = (state) => {
|
|
|
2079
2105
|
0,
|
|
2080
2106
|
state.executionHistory.length - state.config.cleanup.maxExecutionHistory
|
|
2081
2107
|
);
|
|
2082
|
-
logger.
|
|
2108
|
+
logger.debug(`${chalk8.blue("\u{1F9F9} Cleaned up")} ${removed.length} old execution records`);
|
|
2083
2109
|
return removed;
|
|
2084
2110
|
}
|
|
2085
2111
|
return [];
|
|
2086
2112
|
};
|
|
2087
|
-
var startCleanupInterval = (state) => {
|
|
2088
|
-
return setInterval(() => {
|
|
2089
|
-
cleanupExecutionHistory(state);
|
|
2090
|
-
}, state.config.cleanup.cleanupInterval);
|
|
2091
|
-
};
|
|
2092
2113
|
|
|
2093
2114
|
// src/schedule-plugin/core.ts
|
|
2094
2115
|
var DEFAULT_CONFIG2 = {
|
|
@@ -2140,6 +2161,8 @@ var createInitialState = (config) => {
|
|
|
2140
2161
|
executionHistory: [],
|
|
2141
2162
|
isShuttingDown: false,
|
|
2142
2163
|
runningExecutions: 0,
|
|
2164
|
+
isDirty: false,
|
|
2165
|
+
lastCleanupTime: Date.now(),
|
|
2143
2166
|
lastRestartTime: /* @__PURE__ */ new Date(),
|
|
2144
2167
|
config
|
|
2145
2168
|
};
|
|
@@ -2172,18 +2195,18 @@ var createSchedulerFunctions = (state) => {
|
|
|
2172
2195
|
);
|
|
2173
2196
|
const completedExecution = handleExecutionSuccess(execution, result);
|
|
2174
2197
|
state.executions[execution.id] = completedExecution;
|
|
2175
|
-
scheduler.job = updateJobAfterExecution(scheduler.job, execution, state.config);
|
|
2176
2198
|
} catch (error) {
|
|
2177
2199
|
const failedExecution = handleExecutionError(execution, error);
|
|
2178
2200
|
state.executions[execution.id] = failedExecution;
|
|
2179
2201
|
} finally {
|
|
2180
2202
|
scheduler.isRunning = false;
|
|
2181
2203
|
state.runningExecutions--;
|
|
2204
|
+
scheduler.job = updateJobAfterExecution(scheduler.job, execution, state.config);
|
|
2182
2205
|
if (scheduler.job.enabled && !state.isShuttingDown) {
|
|
2183
2206
|
scheduleJobFn(scheduler);
|
|
2184
2207
|
}
|
|
2185
2208
|
if (state.config.persistence.enabled) {
|
|
2186
|
-
|
|
2209
|
+
state.isDirty = true;
|
|
2187
2210
|
}
|
|
2188
2211
|
}
|
|
2189
2212
|
};
|
|
@@ -2205,11 +2228,18 @@ var initializeScheduler = async (state, scheduleJobFn) => {
|
|
|
2205
2228
|
);
|
|
2206
2229
|
state.schedulers = schedulers;
|
|
2207
2230
|
state.executionHistory = executionHistory;
|
|
2208
|
-
if (state.config.persistence.saveInterval > 0) {
|
|
2209
|
-
setInterval(() => saveSchedulerState(state), state.config.persistence.saveInterval);
|
|
2210
|
-
}
|
|
2211
2231
|
}
|
|
2212
|
-
state.
|
|
2232
|
+
const tickInterval = state.config.persistence.saveInterval > 0 ? state.config.persistence.saveInterval : state.config.cleanup.cleanupInterval;
|
|
2233
|
+
state.tickInterval = setInterval(async () => {
|
|
2234
|
+
if (state.isDirty && state.config.persistence.enabled) {
|
|
2235
|
+
state.isDirty = false;
|
|
2236
|
+
await saveSchedulerState(state);
|
|
2237
|
+
}
|
|
2238
|
+
if (Date.now() - state.lastCleanupTime >= state.config.cleanup.cleanupInterval) {
|
|
2239
|
+
state.lastCleanupTime = Date.now();
|
|
2240
|
+
cleanupExecutionHistory(state);
|
|
2241
|
+
}
|
|
2242
|
+
}, tickInterval);
|
|
2213
2243
|
for (const scheduler of Object.values(state.schedulers)) {
|
|
2214
2244
|
if (scheduler.job.enabled) {
|
|
2215
2245
|
scheduleJobFn(scheduler);
|
|
@@ -2240,11 +2270,11 @@ var createJobFromDefinition = (jobDef, config) => {
|
|
|
2240
2270
|
const result = parseCronExpression(cronExpression, void 0, {
|
|
2241
2271
|
timezone: jobDef.timezone ?? config.cron.defaultTimezone
|
|
2242
2272
|
});
|
|
2243
|
-
logger.
|
|
2273
|
+
logger.debug(`${chalk10.blue("\u{1F4C5} Job")} ${chalk10.green(jobDef.name)}: ${result.description} - Next: ${chalk10.cyan(result.nextRun.toLocaleString())}`);
|
|
2244
2274
|
const upcoming = getNextExecutions(cronExpression, 3, {
|
|
2245
2275
|
timezone: jobDef.timezone ?? config.cron.defaultTimezone
|
|
2246
2276
|
});
|
|
2247
|
-
logger.
|
|
2277
|
+
logger.debug(`${chalk10.blue(" Upcoming:")} ${upcoming.map((d) => d.toLocaleTimeString()).join(", ")}`);
|
|
2248
2278
|
}
|
|
2249
2279
|
const job = {
|
|
2250
2280
|
id: generateJobId(),
|
|
@@ -2308,19 +2338,19 @@ var createExecutionsData = (state) => ({
|
|
|
2308
2338
|
running: Object.values(state.executions).filter((e) => e.status === "running")
|
|
2309
2339
|
});
|
|
2310
2340
|
var registerDashboardRoute = (app, state) => {
|
|
2311
|
-
app.get("/dashboard", async function(_, reply) {
|
|
2341
|
+
app.get("/schedule/dashboard", async function(_, reply) {
|
|
2312
2342
|
const dashboardData = createDashboardData(state);
|
|
2313
2343
|
return reply.status(200).send(dashboardData);
|
|
2314
2344
|
});
|
|
2315
2345
|
};
|
|
2316
2346
|
var registerExecutionsRoute = (app, state) => {
|
|
2317
|
-
app.get("/executions", async function(_, reply) {
|
|
2347
|
+
app.get("/schedule/executions", async function(_, reply) {
|
|
2318
2348
|
const executionsData = createExecutionsData(state);
|
|
2319
2349
|
return reply.status(200).send(executionsData);
|
|
2320
2350
|
});
|
|
2321
2351
|
};
|
|
2322
2352
|
var registerTriggerJobRoute = (app, state, executeJobFn) => {
|
|
2323
|
-
app.post("/jobs/:jobId/trigger", async function(request, reply) {
|
|
2353
|
+
app.post("/schedule/jobs/:jobId/trigger", async function(request, reply) {
|
|
2324
2354
|
const scheduler = state.schedulers[request.params.jobId];
|
|
2325
2355
|
if (!scheduler) {
|
|
2326
2356
|
return reply.status(404).send({ error: "Job not found" });
|
|
@@ -2333,7 +2363,7 @@ var registerTriggerJobRoute = (app, state, executeJobFn) => {
|
|
|
2333
2363
|
});
|
|
2334
2364
|
};
|
|
2335
2365
|
var registerEnableJobRoute = (app, state, scheduleJobFn) => {
|
|
2336
|
-
app.put("/jobs/:jobId/enable", async function(request, reply) {
|
|
2366
|
+
app.put("/schedule/jobs/:jobId/enable", async function(request, reply) {
|
|
2337
2367
|
const scheduler = state.schedulers[request.params.jobId];
|
|
2338
2368
|
if (!scheduler) {
|
|
2339
2369
|
return reply.status(404).send({ error: "Job not found" });
|
|
@@ -2345,7 +2375,7 @@ var registerEnableJobRoute = (app, state, scheduleJobFn) => {
|
|
|
2345
2375
|
});
|
|
2346
2376
|
};
|
|
2347
2377
|
var registerDisableJobRoute = (app, state) => {
|
|
2348
|
-
app.put("/jobs/:jobId/disable", async function(request, reply) {
|
|
2378
|
+
app.put("/schedule/jobs/:jobId/disable", async function(request, reply) {
|
|
2349
2379
|
const scheduler = state.schedulers[request.params.jobId];
|
|
2350
2380
|
if (!scheduler) {
|
|
2351
2381
|
return reply.status(404).send({ error: "Job not found" });
|
|
@@ -2459,7 +2489,7 @@ var createSchedulerManager = ({
|
|
|
2459
2489
|
throw new Error(`Job '${jobName}' does not exist`);
|
|
2460
2490
|
}
|
|
2461
2491
|
if (scheduler.job.enabled) {
|
|
2462
|
-
logger.
|
|
2492
|
+
logger.debug(`${logSymbols9.info} ${chalk11.blue("Job is already enabled:")} ${chalk11.magenta(jobName)}`);
|
|
2463
2493
|
return;
|
|
2464
2494
|
}
|
|
2465
2495
|
scheduler.job.enabled = true;
|
|
@@ -2478,7 +2508,7 @@ var createSchedulerManager = ({
|
|
|
2478
2508
|
throw new Error(`Job '${jobName}' does not exist`);
|
|
2479
2509
|
}
|
|
2480
2510
|
if (!scheduler.job.enabled) {
|
|
2481
|
-
logger.
|
|
2511
|
+
logger.debug(`${logSymbols9.info} ${chalk11.blue("Job is already disabled:")} ${chalk11.magenta(jobName)}`);
|
|
2482
2512
|
return;
|
|
2483
2513
|
}
|
|
2484
2514
|
scheduler.job.enabled = false;
|