我要做的是获取jenkins作业详细信息并在每隔“X”分钟将其存储在mongo DB中。我必须制作HTTP.call(JenkinsURL)
,我知道该怎么做。我的问题是在特定的时间间隔内调用它。
buildDetails=HTTP.call('GET',buildURL);
buildURL
包含Jenkins作业网址。我发现这个link概述了我的问题的代码,但我不知道应该如何以及在哪里放置这些代码以使其正常工作。我尽力了。
meteor中是否有任何方法可以运行每X分钟运行一个特定代码?
答案 0 :(得分:1)
Is there any method in meteor which can make this possible to run a specific code to be run for every X min??
Yes, there is.
Meteor.setInterval
that can be used to do something repetitively every X interval of time.
You can put your HTTP call within it on the server. Eg:
Meteor.startup({function(){
var timerID = Meteor.setInterval(function(){
buildDetails=HTTP.call('GET',buildURL);
// and other things
}, 60000) //60000ms = 1 min
}
});
When you want to stop the timer function, simply call Meteor.clearInterval
Meteor.clearInterval(timerID);