Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Workload Scheduler for Node.js script - is it equivalent to cron jobs in Bluemix?

I'm trying to call node file.js with Bluemix Workload Scheduler every morning; file.js is in the root of my node.js project; file.js is not my server file. I used to use cron but it seems like "BlueMix doesn't have a concept of cron jobs."

As result for the (only) step of my process, I got "node : command not found"

I think I missed something. Is it even possible to do this with Workload Scheduler or should I find alternative options?

MORE INFORMATION

I'm trying to do :

var wls = new WorkloadService(credentials);

var wp = new WAProcess("MyProcessName", "DescriptionProcess");
wp.addStep(new CommandStep("node file.js", myAgentName));
wp.addTrigger( TriggerFactory.repeatDaily(1) );

wls.createAndEnableTask(wp, function(res){
    wls.runTask(res.id, function(){console.log("Process is created and started.")});
});

I can see in "IBM Workload Automation on Cloud - Application Lab" that the process is created and started. A few later, process has failed saying "node command not found"

I think i read in the documentation that the agent can only call local system commands (such as cat, pwd ... ) or commands that interact with outside (for REST services call). So there's no way it can find node command or file.js.

Unless I install everything on the agent ? Documentation says we can install programs in /home/wauser/workspace directory by using curl command. Is that how I should proceed ?

like image 999
bluemixer Avatar asked May 12 '15 10:05

bluemixer


1 Answers

You should modify your NodeJS application to let it expose a method that can be run using the curl command and provides the proper output and logging. The curl calling the method will then be run in the Workload Scheduler job. Workload Scheduler service is not part of the node runtime.

like image 126
lmosca Avatar answered Oct 26 '22 23:10

lmosca