How to use the node-schedule.cancelJob function in node-schedule

To help you get started, we’ve selected a few node-schedule examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ioBroker / ioBroker.javascript / main.js View on Github external
}
        }

        // Stop all timeouts
        for (let i = 0; i < context.scripts[name].timeouts.length; i++) {
            clearTimeout(context.scripts[name].timeouts[i]);
        }
        // Stop all intervals
        for (let i = 0; i < context.scripts[name].intervals.length; i++) {
            clearInterval(context.scripts[name].intervals[i]);
        }
        // Stop all scheduled jobs
        for (let i = 0; i < context.scripts[name].schedules.length; i++) {
            if (context.scripts[name].schedules[i]) {
                const _name = context.scripts[name].schedules[i].name;
                if (!nodeSchedule.cancelJob(context.scripts[name].schedules[i])) {
                    adapter.log.error('Error by canceling scheduled job "' + _name + '"');
                }
            }
        }

        // Stop all time wizards jobs
        for (let i = 0; i < context.scripts[name].wizards.length; i++) {
            if (context.scripts[name].wizards[i]) {
                context.scheduler.remove(context.scripts[name].wizards[i]);
            }
        }

        // if callback for on stop
        if (typeof context.scripts[name].onStopCb === 'function') {
            context.scripts[name].onStopTimeout = parseInt(context.scripts[name].onStopTimeout, 10) || 1000;
github klren0312 / stm32_wifi / Nodejs_Server / autofood.js View on Github external
conn.query('select * from autofood', function(err,rows,fields){
				let len = rows.length;
				let tem = rows[len-1].type;
				if (tem !== x) {
					if (schedule.scheduledJobs['feed']) {
						var result = schedule.cancelJob('feed');
						console.log("关闭当前定时: ")
						console.log(result)
					}
					big()
				}else{
					console.log("same")
				}
			})
}
github mimecuvalo / helloworld / packages / social-butterfly / index.js View on Github external
const dispose = () => {
    schedule.cancelJob('updateFeeds');
  };
github ioBroker / ioBroker.javascript / lib / sandbox.js View on Github external
clearSchedule:  function (schedule) {
            if (context.scheduler.get(schedule)) {
                sandbox.verbose && sandbox.log('clearSchedule() => wizard cleared', 'info');
                const pos = script.wizards.indexOf(schedule);
                if (pos !== -1) {
                    script.wizards.splice(pos, 1);
                }
                context.scheduler.remove(schedule);
            } else {
                for (let i = 0; i < script.schedules.length; i++) {
                    if (script.schedules[i] === schedule) {
                        if (!nodeSchedule.cancelJob(script.schedules[i])) {
                            adapter.log.error('Error by canceling scheduled job');
                        }
                        delete script.schedules[i];
                        script.schedules.splice(i, 1);
                        sandbox.verbose && sandbox.log('clearSchedule() => cleared', 'info');
                        return true;
                    }
                }
            }

            sandbox.verbose && sandbox.log('clearSchedule() => invalid handler', 'warn');
            return false;
        },
        setState:       function (id, state, isAck, callback) {

node-schedule

A cron-like and not-cron-like job scheduler for Node.

MIT
Latest version published 1 year ago

Package Health Score

79 / 100
Full package analysis