TritonDataCenter / node-workflow

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

Job Management: Pause/Resume #118

Open Arsca opened 10 years ago

Arsca commented 10 years ago

Hi,

I have been trying to figure out how to put a job on hold and resume it later. The documentation is not so clear on the subject matter. So far, if I understand correctly, during the execution in the task body I should call cb('wait') to put it on hold and the external system can resume it by calling the REST api at '/jobs/jobUuid/resume' . So far I have not managed to do it.

If I use the cb('wait') signal for callback I get the Redis backend error:

/PRUEBA/node_modules/wf-redis-backend/node_modules/redis/index.js:523
            throw err;
                  ^
TypeError: Object #<Object> has no method 'pauseJob'
    at saveJob (node_modules/wf/lib/job-runner.js:191:28)
    at onEnd (/PRUEBA/node_modules/wf/lib/job-runner.js:230:16)
    at onError (/PRUEBA/node_modules/wf/lib/job-runner.js:524:24)
    at /PRUEBA/node_modules/wf/lib/job-runner.js:482:28
    at next (/PRUEBA/node_modules/wf/node_modules/vasync/lib/vasync.js:178:4)
    at /PRUEBA/node_modules/wf/lib/job-runner.js:338:36
    at /PRUEBA/node_modules/wf/lib/job-runner.js:137:32
    at /PRUEBA/node_modules/wf-redis-backend/lib/workflow-redis-backend.js:783:20
    at try_callback (/PRUEBA/node_modules/wf-redis-backend/node_modules/redis/index.js:520:9)
    at RedisClient.return_reply (/PRUEBA/node_modules/wf-redis-backend/node_modules/redis/index.js:590:13)

Would be nice to see an example how to do it.

kind regards,

kusor commented 10 years ago

You're right about using cb('wait') - as noted at http://kusor.github.io/node-workflow/#using-tasks-to-re-queue-retry-or-put-jobs-to-wait - that's definitely an issue with the redid backend. I'll take a look, thanks!