Commits

David Hessing committed f61cf57

Added callback.

Comments (0)

Files changed (2)

 ```
 var Scheduler = require('iron-scheduler');
 var scheduler = Scheduler(ironOauthToken, ironProjectId, winstonLogger);
-scheduler.run(scheduledTasks);
+scheduler.run(scheduledTasks, function(err) {
+    if (err) { 
+        //handle error
+    } else {
+        //scheduler completed successfully. 
+    }
+});
 ```
 The logger is a [winston](https://github.com/flatiron/winston) logger, and is optional. If omitted you'll get console and file logging through a winston console logger; see the config.js file for details.
 The scheduledTasks parameter is an array of tasks in the same format as in the example payload above.
     };
 
 
-    scheduler.run = function (tasks) {
+    scheduler.run = function (tasks, cb) {
         processScheduledTasks(tasks)
             .catch(function (err) {
-                logger.error('Unknown error!');
-                if (err) {
-                    logger.error(err);
+                if (!err) { err = 'Unknown error!'; }
+                logger.error(err);
+                if (cb) {
+                    cb(err);
                 }
             })
             .done(function () {
+                if (cb) {
+                    cb(null);
+                }
             });
     };