task-scheduler-background

0.0.7 • Public • Published

This is the Task Schedular project inspired by Runescape Private Server design for node.js It's very easy to start running tasks in the background of your node application

Here's how to run the task First make sure to add this at the top

const TaskManager = require('task-scheduler-background');

Then anywhere in your node application you can submit a task by doing this

TaskManager.submitTask("Example Task", function() {
 
    if (> 11) {
        return TaskManager.STATE.ERROR;
    } else if (=== 10) {
        return TaskManager.STATE.OFFLINE;
    }
 
    x ++;
    return TaskManager.STATE.ONLINE;
 
}, 1, TaskManager.TimeUnits.SECONDS);

If you ever need the name of the task inside your method you can specify it by doing this

TaskManager.submitTask("Example Task", function(name) {
 
    if (> 11) {
        return TaskManager.STATE.ERROR;
    } else if (=== 10) {
        return TaskManager.STATE.OFFLINE;
    }
 
    x ++;
    console.log('task: ' + name);
    return TaskManager.STATE.ONLINE;
 
}, 1, TaskManager.TimeUnits.SECONDS);

There's five different mearsurements of time you can specify

TaskManager.TimeUnits.MILLISECONDS
TaskManager.TimeUnits.SECONDS
TaskManager.TimeUnits.MINUTES
TaskManager.TimeUnits.HOURS
TaskManager.TimeUnits.DAYS

Also there's three different States the task can be in

TaskManager.STATE.ONLINE - keeps running
TaskManager.STATE.OFFLINE - stops running
TaskManager.STATE.ERROR - stops the task and says which task ran into an error

Package Sidebar

Install

npm i task-scheduler-background

Weekly Downloads

1

Version

0.0.7

License

ISC

Unpacked Size

4.62 kB

Total Files

4

Last publish

Collaborators

  • wantedred