用于Node.js脚本的Workload Scheduler-它等效于Bluemix中的cron作业吗? [英] Workload Scheduler for Node.js script - is it equivalent to cron jobs in Bluemix?

查看:85
本文介绍了用于Node.js脚本的Workload Scheduler-它等效于Bluemix中的cron作业吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图每天早上使用Bluemix Workload Scheduler调用node file.js; file.js在我的node.js项目的根目录中;不是我的服务器文件.我曾经使用cron,但似乎"BlueMix没有cron作业的概念."

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."

作为该过程(仅)步骤的结果,我得到了"node:not found命令"

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

我想我错过了一些东西.甚至可以使用Workload Scheduler进行此操作,还是应该寻找其他选择?

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

更多信息

我正在尝试:

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.")});
});

我可以在"IBM Workload Automation on Cloud-应用程序实验室"中看到该过程已创建并启动.稍后,进程失败,提示找不到节点命令"

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"

我想我在文档中读到,该代理只能调用本地系统命令(例如cat,pwd ...)或与外部进行交互的命令(用于REST服务调用).因此,无法找到节点命令或file.js.

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.

除非我将所有内容都安装在代理上?文档说我们可以使用 curl 命令将程序安装在/home/wauser/workspace目录中.那是我应该怎么做?

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 ?

推荐答案

您应该修改NodeJS应用程序,以使其公开可以使用curl命令运行的方法,并提供正确的输出和日志记录.然后,调用该方法的curl将在Workload Scheduler作业中运行. Workload Scheduler服务不属于节点运行时.

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.

这篇关于用于Node.js脚本的Workload Scheduler-它等效于Bluemix中的cron作业吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆