File tree 3 files changed +12
-1
lines changed
3 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,13 @@ export class JobDbRepository {
57
57
return this . collection . deleteMany ( query ) ;
58
58
}
59
59
60
+ async getQueueSize ( ) : Promise < number > {
61
+ return this . collection . countDocuments ( { nextRunAt : { $lt : new Date ( ) } } ) ;
62
+ }
63
+
64
+ /**
65
+ * Internal method to unlock jobs so that they can be re-run
66
+ */
60
67
async unlockJobs ( jobIds : ObjectId [ ] ) {
61
68
await this . collection . updateMany ( { _id : { $in : jobIds } } , { $set : { lockedAt : null } } ) ;
62
69
}
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ export class JobProcessor {
23
23
24
24
async getStatus ( ) {
25
25
return {
26
+ queueSize : await this . agenda . db . getQueueSize ( ) ,
26
27
jobStatus : this . jobStatus ,
27
28
runningJobs : this . runningJobs . length ,
28
29
lockedJobs : this . lockedJobs . length ,
Original file line number Diff line number Diff line change @@ -50,7 +50,10 @@ export class Agenda extends EventEmitter {
50
50
private ready : Promise < unknown > ;
51
51
52
52
getRunningStats ( ) {
53
- return this . jobProcessor ?. getStatus ( ) ;
53
+ if ( ! this . jobProcessor ) {
54
+ throw new Error ( 'agenda not running!' ) ;
55
+ }
56
+ return this . jobProcessor . getStatus ( ) ;
54
57
}
55
58
56
59
constructor (
You can’t perform that action at this time.
0 commit comments