How do I run a node.js app as a background service?

前端 未结 26 1098
隐瞒了意图╮
隐瞒了意图╮ 2020-11-22 05:28

Since this post has gotten a lot of attention over the years, I\'ve listed the top solutions per platform at the bottom of this post.


Original post

26条回答
  •  太阳男子
    2020-11-22 06:20

    For people using newer versions of the daemon npm module - you need to pass file descriptors instead of strings:

    var fs = require('fs');
    var stdoutFd = fs.openSync('output.log', 'a');
    var stderrFd = fs.openSync('errors.log', 'a');
    require('daemon')({
        stdout: stdoutFd, 
        stderr: stderrFd
    });
    

提交回复
热议问题