2

In some tutorials I've seen the following snippet for monitoring processes with PID:

check process nodejs with pidfile "/var/run/yourprogram.pid"
   start program = "/sbin/start myapp"
   stop program  = "/sbin/stop myapp"
   if failed port 8000 protocol HTTP
      request /
      with timeout 10 seconds
      then restart

But in some others I saw monitoring a whole host without PID like the following:

check host localhost with address 127.0.0.1
    start "/sbin/start myapp"
    stop "/sbin/stop myapp"
    if failed port 8000 protocol HTTP
       request /
       with timeout 10 seconds
       then restart

Tell me what is the difference in these two approaches? Which is better for monitoring of node js?

Peter
  • 5,403
  • 1
  • 25
  • 32
Erik
  • 203
  • 2
  • 5
  • 13

1 Answers1

1

Process Identifier is actually useful when something goes wrong and/or you have more instances of the very same process running on your system. If you then want to to debug or kill, you can immediately track your process by it's ID rather then guessing one of multiple names.

Ali V
  • 96
  • 4
  • Hmm. It's very interesting. Is it possible to run several nodejs instances in a single machine and track pid of each one? – Erik May 21 '13 at 12:58
  • I have really only elementary experience in the programming as a whole, but in my opininon - yes it is possible if you call the system's function to get the current program's PID from inside the program and have it report for example IP address you are starting this for followed by its PID. – Ali V May 21 '13 at 13:04