jm2 0.1.10 → 0.1.12
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/package.json +1 -1
- package/src/core/service.js +0 -4
- package/src/daemon/scheduler.js +15 -10
package/package.json
CHANGED
package/src/core/service.js
CHANGED
|
@@ -178,8 +178,6 @@ class DarwinService extends PlatformService {
|
|
|
178
178
|
</array>
|
|
179
179
|
<key>RunAtLoad</key>
|
|
180
180
|
<true/>
|
|
181
|
-
<key>KeepAlive</key>
|
|
182
|
-
<true/>
|
|
183
181
|
<key>StandardOutPath</key>
|
|
184
182
|
<string>${stdoutPath}</string>
|
|
185
183
|
<key>StandardErrorPath</key>
|
|
@@ -344,8 +342,6 @@ Type=forking
|
|
|
344
342
|
ExecStart=${nodePath} ${jm2Path} start
|
|
345
343
|
ExecStop=${nodePath} ${jm2Path} stop
|
|
346
344
|
ExecReload=${nodePath} ${jm2Path} restart
|
|
347
|
-
Restart=always
|
|
348
|
-
RestartSec=10
|
|
349
345
|
Environment="JM2_DATA_DIR=${dataDir}"
|
|
350
346
|
StandardOutput=append:${join(logDir, 'service-out.log')}
|
|
351
347
|
StandardError=append:${join(logDir, 'service-err.log')}
|
package/src/daemon/scheduler.js
CHANGED
|
@@ -196,6 +196,7 @@ export class Scheduler {
|
|
|
196
196
|
/**
|
|
197
197
|
* Recalculate next run times for periodic jobs that have drifted into the past
|
|
198
198
|
* This handles system sleep/wake scenarios where nextRun becomes stale
|
|
199
|
+
* Only recalculates jobs that are significantly overdue (missed multiple runs)
|
|
199
200
|
* @param {Date} now - Current time
|
|
200
201
|
*/
|
|
201
202
|
recalculateStalePeriodicJobs(now) {
|
|
@@ -204,17 +205,21 @@ export class Scheduler {
|
|
|
204
205
|
job.status === JobStatus.ACTIVE &&
|
|
205
206
|
job.type === JobType.CRON &&
|
|
206
207
|
job.cron &&
|
|
207
|
-
job.nextRun
|
|
208
|
-
job.nextRun < now
|
|
208
|
+
job.nextRun
|
|
209
209
|
) {
|
|
210
|
-
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
)
|
|
217
|
-
|
|
210
|
+
const timeSinceNextRun = now.getTime() - job.nextRun.getTime();
|
|
211
|
+
const isSignificantlyOverdue = timeSinceNextRun > this.checkIntervalMs * 2;
|
|
212
|
+
|
|
213
|
+
if (isSignificantlyOverdue) {
|
|
214
|
+
// Job is significantly overdue - recalculate from now to find next future occurrence
|
|
215
|
+
const newNextRun = this.calculateNextRun(job, now);
|
|
216
|
+
if (newNextRun && newNextRun !== job.nextRun) {
|
|
217
|
+
this.logger.debug(
|
|
218
|
+
`Recalculating next run for job ${id} (${job.name || 'unnamed'}): ` +
|
|
219
|
+
`${job.nextRun.toISOString()} → ${newNextRun.toISOString()}`
|
|
220
|
+
);
|
|
221
|
+
this.updateJobNextRun(id, newNextRun);
|
|
222
|
+
}
|
|
218
223
|
}
|
|
219
224
|
}
|
|
220
225
|
}
|