我正在使用judo.js创建我的Ember Web应用程序的站点地图和HTML快照。对网站上基本URL的简单测试失败。站点地图生成得很好,但是不管urlconfig对象包含多少url(或者页面有多小),它都会抛出一个“stdout maxbuffer exceeded”错误。
首先它记录Preparing to snapshot: 2(其中2是我指定的url)。
然后记录Finished snapshotting: 2
然而,它会“挂”约6秒并吐出:

 Error: stdout maxBuffer exceeded]
    cmd: 'C:\Windows\\system31\\cmd.exe /s /c "phantom.js c:\\Temp\\visitlakesnapshots\\node_modules\\judo\\lib\\phantomjs-runner.js
 http://www.mywebsite.com/dine"

我做错什么了?我可以修改幻影的maxbuffer吗?但似乎没有一个页面会超过请求大小。
编辑:
当我只运行一个很小的页面…确保它低于200K,它工作。我发现文档中maxbuffer的默认值是200k,所以我需要知道在使用柔道时如何增加maxbuffer选项。我发现了这个,但不知道如何将其合并到我现有的代码中:
var execute = function(command, callback){
    exec(command, {maxBuffer: 1024 * 500}, function(error, stdout, stderr){
           callback(error, stdout); });
};

下面是我用node运行的脚本文件:
var http = require('http');
http.createServer(function (req, res) {
   res.writeHead(200, {'Content-Type': 'text/plain'});
   //res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');


var options = {
   muteWarnings: false,   // mute warnings generated by Judo
    phantomProcs: 5      // Number of PhantomJS processes to run concurrently. Had 1 here, changed to 5...makes no difference.
};

var Judo = require('judo');
var judo = new Judo(options);


var urlConfig = {
    baseUrl: 'http://www.visitlakefl.com',     // The base URL of your site
    siteMapPath: 'E:/Websites/VisitLake/sitemap.xml',  // Sitemap output
    snapshotsDir: 'E:/Websites/VisitLake/Views/Snapshots',
    urls: [
        {
            url: '/',
            siteMap: {   changefreq: 'daily' },
            snapshot: { changefreq: 'daily',filenames: ['index.html','home.html']}
        },
         {
            url: '/play',
            siteMap: {   changefreq: 'daily' },
            snapshot: { changefreq: 'daily',filenames: ['play/index.html']}
        },
        {
           url: '/dine',
           siteMap: {  changefreq: 'daily'},
           snapshot: {changefreq: 'daily',filenames: ['dine/index.html']}
       }
    ]
};


//judo.updateSiteMap(urlConfig, function(err){
    //if (!err) console.log('that was easy!');
//});

judo.createSnapshots(urlConfig, function(err){
    if (!err) { console.log('snapshots created. That was easy!');
           process.exit();
        } else {
      console.log(err);
           process.exit();
    }
});

最佳答案

解决此问题的myPR已合并。如果从GitHub获得最新版本的柔道,现在可以在选项中指定maxBuffer设置,如下所示:

var options = {
    muteWarnings: false,        // Allows the user to mute warnings generated by Judo
    phantomProcs: 1,            // Number of PhantomJS processes to run concurrently
    maxBuffer: 200*1024         // Max PhantomJS output buffer size
};

var judo = new Judo(options);

一旦将maxbuffer设置为大于站点上最大页面的值,错误就会消失。

关于node.js - 如何在柔道中设置maxBuffer,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29476916/

10-11 20:52