File tree Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -329,6 +329,7 @@ Common.retErr = function(e) {
329
329
Common . sink = { } ;
330
330
331
331
Common . sink . determineCron = function ( app ) {
332
+ const cronParser = require ( 'cron-parser' )
332
333
const scheduleJob = require ( 'node-schedule' ) . scheduleJob ;
333
334
334
335
if ( app . cron_restart == 0 || app . cron_restart == '0' ) {
@@ -339,9 +340,7 @@ Common.sink.determineCron = function(app) {
339
340
if ( app . cron_restart ) {
340
341
try {
341
342
Common . printOut ( cst . PREFIX_MSG + 'cron restart at ' + app . cron_restart ) ;
342
- scheduleJob ( app . cron_restart , function ( ) {
343
- Common . printOut ( cst . PREFIX_MSG + 'cron pattern for auto restart detected and valid' ) ;
344
- } ) ;
343
+ cronParser . parseExpression ( app . cron_restart ) ;
345
344
} catch ( ex ) {
346
345
return new Error ( `Cron pattern error: ${ ex . message } ` ) ;
347
346
}
Original file line number Diff line number Diff line change @@ -54,7 +54,10 @@ module.exports = function(God) {
54
54
return ;
55
55
console . log ( '[PM2] Deregistering a cron job on:' , id ) ;
56
56
var job = God . CronJobs . get ( God . getCronID ( id ) ) ;
57
- job . cancel ( ) ;
57
+
58
+ if ( job )
59
+ job . cancel ( ) ;
60
+
58
61
God . CronJobs . delete ( God . getCronID ( id ) ) ;
59
62
} ;
60
63
Original file line number Diff line number Diff line change 177
177
"cli-tableau" : " ^2.0.0" ,
178
178
"commander" : " 2.15.1" ,
179
179
"node-schedule" : " ^2.0.0" ,
180
+ "cron-parser" : " ~3.5.0" ,
180
181
"dayjs" : " ~1.8.25" ,
181
182
"debug" : " ^4.3.1" ,
182
183
"enquirer" : " 2.3.6" ,
You can’t perform that action at this time.
0 commit comments