Skip to content

Commit b0af9d2

Browse files
author
Dmitry Ovsyanko
committed
Queue + stop ()
1 parent e0ccca8 commit b0af9d2

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/Queue.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,19 @@ class Queue extends JobSource {
99

1010
super (app, o)
1111

12-
if ('cron' in o) {
12+
if ('cron' in o) this.cron = new Cron (o.cron, {}, () => this.check ())
1313

14-
const cron = new Cron (o.cron, {}, () => this.check ())
15-
16-
this.cron = cron
14+
app.once ('finish', () => this.stop ())
1715

18-
app.once ('finish', () => cron.stop ())
16+
}
1917

20-
}
18+
stop () {
19+
20+
if ('cron' in this) this.cron.stop ()
21+
22+
this.app.jobSources.delete (this.name)
23+
24+
this.isStopped = true
2125

2226
}
2327

0 commit comments

Comments
 (0)