honkew
V2EX  ›  Node.js

nodejs 执行系统命令,等待时间过长

  •  
  •   honkew · Nov 11, 2016 · 4134 views
    This topic created in 3490 days ago, the information mentioned may be changed or developed.

    process.exec(command, function (error, stdout, stderr) {

    }

    然后超过 20 分钟就会执行 function 里面的内容 但是 cmd 进程还在继续执行,也就是命令没有执行完毕

    1 replies    2016-11-11 19:48:25 +08:00
    cxbig
        1
    cxbig  
       Nov 11, 2016
    执行时间太长的命令考虑拆分成一组小任务,或者启用任务队列, app 这边的任务触发和查看结果都是即时反馈,不会造成 timeout 。
    另外做一个执行锁来避免同任务重复执行。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3303 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 14:00 · PVG 22:00 · LAX 07:00 · JFK 10:00
    ♥ Do have faith in what you're doing.