Saturday, May 12, 2012

First error with node.js

This week I started to read "Node up and running" book, and followed the examples to explore node.js which is really promising for javascript on server side. Installing node, or setup other libraries using NPM is quite easy, and running sample node.js is also trivia. However, my ever first error from node.js is as below
node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: listen EADDRINUSE
    at errnoException (net.js:614:11)
    at Array.0 (net.js:704:26)
    at EventEmitter._tickCallback (node.js:192:40)
It is quite understandable from "listen EADDRINUSE", the error means some other process already occupy the address. But I did quit original node process.

Well, did a quick check ps aux | grep node found the previous node process was still there, but I did Ctrl-Z, right? So far I have not realized the root cause, so I went ahead to kill -9 node-PID to get rid of previous node process, and get the updated node.js running.

Why previous quite (Ctrl-Z) didn't work? Quickly checked wikipedia and found the answer
http://en.wikipedia.org/wiki/Signal_%28computing%29

  • Ctrl-C (in older Unixes, DEL) sends an INT signal (SIGINT); by default, this causes the process to terminate.
  • Ctrl-Z sends a TSTP signal (SIGTSTP); by default, this causes the process to suspend execution.
It is clear that I should use Ctrl-C to terminate the node process, or kill the process.

1 comment: