@webtypen/webframez-core 0.3.1 → 0.3.3
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.
|
@@ -89,6 +89,9 @@ class QueueWorkerCommand extends ConsoleCommand_1.ConsoleCommand {
|
|
|
89
89
|
if (!this.canStart()) {
|
|
90
90
|
return false;
|
|
91
91
|
}
|
|
92
|
+
if (!fs_1.default.existsSync((0, FileFunctions_1.storageDir)("queue"))) {
|
|
93
|
+
fs_1.default.mkdirSync((0, FileFunctions_1.storageDir)("queue"), { recursive: true });
|
|
94
|
+
}
|
|
92
95
|
const filePath = (0, FileFunctions_1.storageDir)("queue", `worker_${this.workerKey}.json`);
|
|
93
96
|
let lastLogFile = null;
|
|
94
97
|
if (fs_1.default.existsSync(filePath)) {
|
|
@@ -389,7 +392,7 @@ class QueueWorkerCommand extends ConsoleCommand_1.ConsoleCommand {
|
|
|
389
392
|
const executionKey = (0, moment_timezone_1.default)()
|
|
390
393
|
.tz(this.workerConfig.timezone ? this.workerConfig.timezone : "Europe/Berlin")
|
|
391
394
|
.format("YYYYMMDDHHmmss") + StringFunctions_1.StringFunctions.random(24);
|
|
392
|
-
const
|
|
395
|
+
const jobUpdate = yield connection.client
|
|
393
396
|
.db(null)
|
|
394
397
|
.collection("queue_jobs")
|
|
395
398
|
.findOneAndUpdate({
|
|
@@ -400,10 +403,10 @@ class QueueWorkerCommand extends ConsoleCommand_1.ConsoleCommand {
|
|
|
400
403
|
worker: { $in: [null, this.workerKey] },
|
|
401
404
|
$or: [
|
|
402
405
|
{
|
|
403
|
-
|
|
406
|
+
not_before: null,
|
|
404
407
|
},
|
|
405
408
|
{
|
|
406
|
-
|
|
409
|
+
not_before: { $lte: now.toDate() },
|
|
407
410
|
},
|
|
408
411
|
],
|
|
409
412
|
}, {
|
|
@@ -416,6 +419,11 @@ class QueueWorkerCommand extends ConsoleCommand_1.ConsoleCommand {
|
|
|
416
419
|
sort: { priority: -1, created_at: 1 },
|
|
417
420
|
returnDocument: "after",
|
|
418
421
|
});
|
|
422
|
+
const job = jobUpdate && jobUpdate.jobclass && jobUpdate._id
|
|
423
|
+
? jobUpdate
|
|
424
|
+
: jobUpdate.value && jobUpdate.ok && jobUpdate.value._id && jobUpdate.value.jobclass
|
|
425
|
+
? jobUpdate.value
|
|
426
|
+
: null;
|
|
419
427
|
if (!job || !job.jobclass || !job._id) {
|
|
420
428
|
this.currentJob = null;
|
|
421
429
|
if (job && job._id) {
|
package/package.json
CHANGED
|
@@ -84,6 +84,10 @@ export class QueueWorkerCommand extends ConsoleCommand {
|
|
|
84
84
|
return false;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
if (!fs.existsSync(storageDir("queue"))) {
|
|
88
|
+
fs.mkdirSync(storageDir("queue"), { recursive: true });
|
|
89
|
+
}
|
|
90
|
+
|
|
87
91
|
const filePath = storageDir("queue", `worker_${this.workerKey}.json`);
|
|
88
92
|
let lastLogFile: any = null;
|
|
89
93
|
if (fs.existsSync(filePath)) {
|
|
@@ -465,7 +469,7 @@ export class QueueWorkerCommand extends ConsoleCommand {
|
|
|
465
469
|
moment()
|
|
466
470
|
.tz(this.workerConfig.timezone ? this.workerConfig.timezone : "Europe/Berlin")
|
|
467
471
|
.format("YYYYMMDDHHmmss") + StringFunctions.random(24);
|
|
468
|
-
const
|
|
472
|
+
const jobUpdate = await connection.client
|
|
469
473
|
.db(null)
|
|
470
474
|
.collection("queue_jobs")
|
|
471
475
|
.findOneAndUpdate(
|
|
@@ -478,10 +482,10 @@ export class QueueWorkerCommand extends ConsoleCommand {
|
|
|
478
482
|
worker: { $in: [null, this.workerKey] },
|
|
479
483
|
$or: [
|
|
480
484
|
{
|
|
481
|
-
|
|
485
|
+
not_before: null,
|
|
482
486
|
},
|
|
483
487
|
{
|
|
484
|
-
|
|
488
|
+
not_before: { $lte: now.toDate() },
|
|
485
489
|
},
|
|
486
490
|
],
|
|
487
491
|
},
|
|
@@ -498,6 +502,13 @@ export class QueueWorkerCommand extends ConsoleCommand {
|
|
|
498
502
|
}
|
|
499
503
|
);
|
|
500
504
|
|
|
505
|
+
const job =
|
|
506
|
+
jobUpdate && jobUpdate.jobclass && jobUpdate._id
|
|
507
|
+
? jobUpdate
|
|
508
|
+
: jobUpdate.value && jobUpdate.ok && jobUpdate.value._id && jobUpdate.value.jobclass
|
|
509
|
+
? jobUpdate.value
|
|
510
|
+
: null;
|
|
511
|
+
|
|
501
512
|
if (!job || !job.jobclass || !job._id) {
|
|
502
513
|
this.currentJob = null;
|
|
503
514
|
|