TritonDataCenter / node-workflow

Task orchestration, creation and running using NodeJS
MIT License
456 stars 66 forks source link

workflow-runner doesn't seem to work correctly - it keeps saying that the same job has ran successfully over and over tho. #93

Closed mirekm closed 11 years ago

mirekm commented 11 years ago

Forgive me if I miss something obvious but for some reason the code below doesn't seem to work correctly with bin/workflow-runner. It seems that the runner picks up the same job repeatedly over and over:

"Job with uuid 33060f47-66a8-42f2-aaac-f95f0894c316 ran successfully"

I use wf-redis-backend.

factory.workflow({
    name: 'Sample Workflow',
    chain: [
      {
        name: 'A Task',
        timeout: 30,
        retry: 2,
        body: function(job, cb) {
          if (!job.foo) {
            job.foo = true;
            return cb('Foo was not defined');
          } else {
            return cb(null);
          }
        }
      }, {
        name: 'Another task',
        body: function(job, cb) {
          return cb('Task body error');
        },
        fallback: function(err, job, cb) {
          job.the_err = err;
          return cb(null);
        }
      }
    ],
    timeout: 30
  }, function(error, wf) {
    assert.ifError(error);
    assert.ok(wf);
    console.log("New workflow uuid:", wf.uuid);
    factory.job({
      workflow: wf.uuid
    });
mirekm commented 11 years ago

The problem was caused by the exec_after property being returned as a string which couldn't be evaluated to the proper date by runner's runNow method. Simple fix can be found here

kusor commented 11 years ago

Hi Mirek!,

Thanks for the pull request. Merged it into redis backend. It should be working fine now.