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) {
329329Common . sink = { } ;
330330
331331Common . sink . determineCron = function ( app ) {
332+ const cronParser = require ( 'cron-parser' )
332333 const scheduleJob = require ( 'node-schedule' ) . scheduleJob ;
333334
334335 if ( app . cron_restart == 0 || app . cron_restart == '0' ) {
@@ -339,9 +340,7 @@ Common.sink.determineCron = function(app) {
339340 if ( app . cron_restart ) {
340341 try {
341342 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 ) ;
345344 } catch ( ex ) {
346345 return new Error ( `Cron pattern error: ${ ex . message } ` ) ;
347346 }
Original file line number Diff line number Diff line change @@ -54,7 +54,10 @@ module.exports = function(God) {
5454 return ;
5555 console . log ( '[PM2] Deregistering a cron job on:' , id ) ;
5656 var job = God . CronJobs . get ( God . getCronID ( id ) ) ;
57- job . cancel ( ) ;
57+
58+ if ( job )
59+ job . cancel ( ) ;
60+
5861 God . CronJobs . delete ( God . getCronID ( id ) ) ;
5962 } ;
6063
Original file line number Diff line number Diff line change 177177 "cli-tableau" : " ^2.0.0" ,
178178 "commander" : " 2.15.1" ,
179179 "node-schedule" : " ^2.0.0" ,
180+ "cron-parser" : " ~3.5.0" ,
180181 "dayjs" : " ~1.8.25" ,
181182 "debug" : " ^4.3.1" ,
182183 "enquirer" : " 2.3.6" ,
You can’t perform that action at this time.
0 commit comments