V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
anexplore
V2EX  ›  程序员

phantomjs 卡住, cpu 100%

  •  
  •   anexplore · 2016-08-03 18:42:52 +08:00 · 4787 次点击
    这是一个创建于 2825 天前的主题,其中的信息可能已经有所发展或是发生改变。

    执行如下命令,发现卡住了,而且一个线程把 cpu 搞到 100%了,除了 kill 有啥方法解决这个问题?

    render_multi_url.js 在 examples 包里

    bin/phantomjs --debug=true render_multi_url.js "www.tlnews.cn/forum/forumdisplay.php?fid=54573"
    
    8 条回复    2016-08-04 11:40:51 +08:00
    zhouyg
        1
    zhouyg  
       2016-08-03 18:53:15 +08:00
    那个 render_multi_url.js 是啥
    bdbai
        2
    bdbai  
       2016-08-03 19:56:53 +08:00 via Android
    为什么不直接发请求呢
    anexplore
        3
    anexplore  
    OP
       2016-08-03 20:02:58 +08:00
    我需要保存页面 截图
    TaMud
        4
    TaMud  
       2016-08-04 00:51:01 +08:00
    page.onError = function(msg, trace) {
    var msgStack = ['ERROR: ' + msg];
    console.error(msgStack.join('\n'));
    phantom.exit();
    };
    anexplore
        5
    anexplore  
    OP
       2016-08-04 09:50:33 +08:00
    @TaMud 这个不起作用,这儿没有 error 事件,具体请看 https://github.com/ariya/phantomjs/issues/14444
    willis
        6
    willis  
       2016-08-04 11:36:37 +08:00   ❤️ 1
    timeout 10 phantomjs --debug=true render_multi_url.js "www.tlnews.cn/forum/forumdisplay.php?fid=54573"
    willis
        7
    willis  
       2016-08-04 11:37:11 +08:00
    timeout 命令有些发行版要自己装
    willis
        8
    willis  
       2016-08-04 11:40:51 +08:00
    还有可以用 nice 命令调整 cpu 优先级,要 root
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1083 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 18:51 · PVG 02:51 · LAX 11:51 · JFK 14:51
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.