相关疑难解决方法(0)

在服务器上调用Collection.insert时,"Meteor代码必须始终在Fiber中运行"

我在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)

javascript meteor node-fibers

38
推荐指数
3
解决办法
2万
查看次数

客户端断开连接后的服务器清理

有没有办法通过刷新或导航离开页面来检测客户端何时断开与流星服务器的连接,以便服务器可以尝试进行一些清理?

javascript meteor

20
推荐指数
2
解决办法
5848
查看次数

标签 统计

javascript ×2

meteor ×2

node-fibers ×1