0

I have 10 NodeJS servers running on 10 separate machines.

They are running with Forever, which keeps them up if they crash, and restarts them if a file changes.

I would like to restart them by clicking on a button in an HTML page. Because nodeJS isn't open to the external world, but only accessible from within the machines, I would like to use a PHP script as a "bridge" between the external world and Node. The button would send a POST request to a PHP script, which could then in some way tell Forever to restart the NodeJS process.

First question, do I need to have a PHP script on each server, and to ask each one of those scripts to restart NodeJS on its own machine ? Or can I have one server with a PHP script which could in someway notify all the servers (I know their local IPs of course) to restart their NodeJS processes ?

I thought about doing this by sending process signals, but of course I cannot do that over a network.

What do you think ?

Rayjax
  • 7,494
  • 11
  • 56
  • 82
  • Any reason why they *need* restarting? – Ben Fortune Nov 13 '14 at 11:42
  • Because even if any known cause of crashing or hanging has been found and fixed, it is always safe to have some easy and fast ways to have control over this kind of things. Because you never know – Rayjax Nov 13 '14 at 17:15

1 Answers1

0

I ended up using the Watch option in Forever which listens for file changes in the folder. The restart button updates a "timestamp" file, which causes forever to restart. Because of NFS replication, this is propagated to all the machines. Not the best solution I guess, it works, but I would gladly do something better

Rayjax
  • 7,494
  • 11
  • 56
  • 82