进行更改后无法重新启动节点服务器

时间:2017-11-06 14:23:59

标签: node.js

我对测试服务器所做的一些代码更改没有生效。我试图确保在更改后正确地重新启动节点服务器。以下是名称“node”显示为正在运行的进程 -

[root@ip-10-30-30-4 lib]# ps -aux | grep node
root     18643  0.0  0.7 916304 26544 ?        Ssl  17:22   0:00 /usr/bin/node /usr/lib/node_modules/forever/bin/monitor app.js
root     21479  0.0  1.7 980380 62528 ?        Sl   19:31   0:00 /root/.nvm/v7.2.1/bin/node /usr/local/mvc/MVC2.0/app.js
root     21491  0.0  2.1 972432 78220 ?        Sl   19:31   0:00 /usr/bin/node /usr/local/mvc/MVC2.0/app.js
root     21858  0.0  0.0 112652   960 pts/1    S+   19:48   0:00 grep --color=auto node
root     22515  0.0  0.8 920548 31008 ?        Ssl  Nov03   0:00 /root/.nvm/v7.2.1/bin/node /usr/lib/node_modules/forever/bin/monitor app.js

我尝试杀死运行app.js(ID为21479和21491)的节点进程,不包括PID 18643和22515.它似乎是监视脚本,它会在停止后立即重新启动服务器。这是它的内容 -

var fs = require('fs'),
    path = require('path'),
    forever = require(path.resolve(__dirname, '..', 'lib', 'forever')),
    started;

//
// ### @function (file, pid)
// #### @file {string} Location of the pid file.
// #### @pid {number} pid to write to disk.
// Write the pidFile to disk for later use
//
function writePid(file, pid) {
  fs.writeFileSync(file, pid, 'utf8');
}

//
// ### @function start (options)
// #### @options {Object} Options for the `forever.Monitor` instance.
// Starts the child process and disconnects from the IPC channel.
//
function start(options) {
  var script = process.argv[2],
      monitor = new forever.Monitor(script, options);

  forever.logEvents(monitor);
  monitor.start();

  monitor.on('start', function () {
    //
    // This starts an nssocket server, which the forever CLI uses to
    // communicate with this monitor process after it's detached.
    // Without this, `forever list` won't show the process, even though it
    // would still be running in the background unaffected.
    //
    forever.startServer(monitor);

    //
    // Disconnect the IPC channel, letting this monitor's parent process know
    // that the child has started successfully.
    //
    process.disconnect();

    //

一旦我使用以下命令终止进程 -

kill <PID>

我仍然看到具有新进程ID的相同进程,这确认了进程已重新启动。但是,这些变化仍然没有反映出来。我应该杀死PID为18643和22515的那些吗?我不确定它是如何实际运行的。

0 个答案:

没有答案