Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js脚本的工作负载调度器-它是否等同于Bluemix中的cron作业?_Node.js_Scheduler_Ibm Cloud - Fatal编程技术网

Node.js脚本的工作负载调度器-它是否等同于Bluemix中的cron作业?

Node.js脚本的工作负载调度器-它是否等同于Bluemix中的cron作业?,node.js,scheduler,ibm-cloud,Node.js,Scheduler,Ibm Cloud,我每天早上都试图用Bluemix Workload Scheduler调用节点文件.js;file.js位于my node.js项目的根目录中;file.js不是我的服务器文件。我以前使用cron,但看起来 作为流程的(唯一)步骤的结果,我得到了“node:command not found” 我想我错过了什么。甚至可以用Workload Scheduler来实现这一点吗?或者我应该找到其他选项吗 更多信息 我正在努力做到: var wls = new WorkloadService(crede

我每天早上都试图用Bluemix Workload Scheduler调用
节点文件.js
;file.js位于my node.js项目的根目录中;file.js不是我的服务器文件。我以前使用cron,但看起来

作为流程的(唯一)步骤的结果,我得到了“node:command not found”

我想我错过了什么。甚至可以用Workload Scheduler来实现这一点吗?或者我应该找到其他选项吗

更多信息

我正在努力做到:

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.")});
});
我可以在“IBMWorkloadAutomationCloud-ApplicationLab”中看到该过程已经创建并启动。几天后,进程在说“未找到节点命令”时失败

我想我在文档中读到代理只能调用本地系统命令(如cat、pwd…)或与外部交互的命令(用于REST服务调用)。所以它无法找到node命令或file.js


除非我在代理上安装所有东西?文档说明我们可以使用curl命令在
/home/wauser/workspace
目录中安装程序。我应该这样做吗?

我想您的应用程序正在使用Bluemix中的内置node.js buildpack。如果这是真的,那么节点应该在路径中。但我不清楚这个调度器服务是否能正确解析命令“node file.js”。也许它只需要一个没有参数的命令?您是否可以尝试放置一个执行“node file.js”的脚本文件,比如run.sh,然后让CommandStep调用此脚本?

您应该修改NodeJS应用程序,使其公开一个可以使用curl命令运行的方法,并提供适当的输出和日志记录。然后,调用该方法的curl将在Workload Scheduler作业中运行。
工作负载调度器服务不是节点运行时的一部分。

正如lmosca在她的回答中所说,工作负载调度器服务在node.js外部运行,但您可以使用它触发在node.js上运行并作为REST公开的代码


除了使用curl,您还可以在Workload Scheduler中定义流程中的REST步骤,以便在不使用curl的情况下调用REST API。

您能再解释一下吗?添加了更多信息后续,您是否仍然存在此问题?不幸的是,我无法在这方面花费更多时间。我只是放弃了。也许我只是不明白它的作用。我用一个好的旧while循环替换了调度程序…我也面临这个问题。你解决过吗,@bluemixer?