【问题标题】:Node Forever Error节点永远错误
【发布时间】:2014-10-15 02:56:02
【问题描述】:

我正在尝试使用 node-forever,但尝试启动它时出现错误。

我将此文件命名为 start.js

var forever = require('forever-monitor');

  var child = new (forever.Monitor)('app-index.js', {
    'silent': false,
    'watch': true,
    'logFile': '/srv/http/mywebsite.com/logs/forever.log', // Path to log output from forever process (when daemonized)
    'outFile': '/srv/http/mywebsite.com/logs/node-stdout.log', // Path to log output from child stdout
    'errFile': '/srv/http/mywebsite.com/logs/node-stderr.log'  // Path to log output from child stderr
  });

  child.on('exit', function () {
    console.log('admin/app-index.js has exited');
  });

  child.start();

这是我运行 node start.js 时发生的情况

path.js:360
        throw new TypeError('Arguments to path.join must be strings');
              ^
TypeError: Arguments to path.join must be strings
    at path.js:360:15
    at Array.filter (native)
    at Object.exports.join (path.js:358:36)
    at exports.attach (/srv/http/mywebsite.com/public/admin/node_modules/forever-monitor/lib/forever-monitor/plugins/watch.js:45:20)
    at Object.bootstrap (/srv/http/mywebsite.com/public/admin/node_modules/forever-monitor/lib/forever-monitor/monitor.js:35:28)
    at exports.App (/srv/http/mywebsite.com/public/admin/node_modules/forever-monitor/node_modules/broadway/lib/broadway/app.js:47:21)
    at new exports.Monitor (/srv/http/mywebsite.com/public/admin/node_modules/forever-monitor/lib/forever-monitor/monitor.js:118:16)
    at Object.<anonymous> (/srv/http/mywebsite.com/public/admin/start.js:3:15)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)

有什么帮助吗?

【问题讨论】:

    标签: javascript node.js forever


    【解决方案1】:

    问题是你设置了watch: true,但没有设置watchDirectory

    默认watchDirectory 为空,但必须是字符串路径。这似乎没有很好的记录。

    在您的情况下,以下应该可以解决您的问题:

    var child = new (forever.Monitor)('app-index.js', {
        'silent': false,
        'watch': true,
        'watchDirectory': '/srv/http/mywebsite.com/public/',
        // ... etc.
    });
    

    【讨论】:

      猜你喜欢
      • 2019-07-14
      • 2018-08-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-12
      • 2014-06-06
      • 2015-08-31
      • 2021-06-04
      相关资源
      最近更新 更多