我在server/statusboard.js中有以下代码;
var require = __meteor_bootstrap__.require,
request = require("request")
function getServices(services) {
services = [];
request('http://some-server/vshell/index.php?type=services&mode=json', function (error, response, body) {
var resJSON = JSON.parse(body);
_.each(resJSON, function(data) {
var host = data["host_name"];
var service = data["service_description"];
var hardState = data["last_hard_state"];
var currState = data["current_state"];
services+={host: host, service: service, hardState: hardState, currState: currState};
Services.insert({host: host, service: service, hardState: hardState, currState: currState});
});
});
}
Meteor.startup(function () {
var services = [];
getServices(services);
console.log(services);
});
Run Code Online (Sandbox Code Playgroud)
基本上,它从JSON提要中提取一些数据并尝试将其推送到集合中.
当我启动Meteor时,我得到以下异常;
app/packages/livedata/livedata_server.js:781
throw exception;
^
Error: Meteor …Run Code Online (Sandbox Code Playgroud) 有没有办法通过刷新或导航离开页面来检测客户端何时断开与流星服务器的连接,以便服务器可以尝试进行一些清理?