Execute a node script indefinitely to query a DB?

0

I have some nodejs scripts to query a mongo Db, but what I want is that this script is running indefinitely, maybe with a 5 minute sleep, and if it stops there is another script that he "revives" him.

Any ideas on how to do these processes? Is another script that is running the service and another script that supervises the first one active? and if so, any examples?

    
asked by J.Correa 02.12.2016 в 18:57
source

2 answers

0

The easiest thing to do would be to create an infinite loop and wait for 5 minutes and then call a function. with setTimeout it should not be complicated, here we respond to something very similar with useful examples.

    
answered by 14.12.2016 / 00:18
source
0

You could use the npm forever package, this helps you "revive" your application.

link

    
answered by 07.01.2017 в 21:12