Deepak Garg
Deepak Garg

Reputation: 83

How to stop server from termination in nodejs?

I have dynamic values in the array (say 100) all values are Neo4j database queries (cypher) each queries brings 30 values from the server.

sometimes if an error occurs in say xyz number query, to handle those error occurred, I have used process.exit() in catch() of the session of Cypher query, because I want to stop complete execution and also discard previous values, but as it also kills the running server.

I want to evaluate everything from starting, I want to restart the server again automatically.

or

Any other way in spite of using process.exit(), if there is anything which I can call so that my current execution stops and restart current request again from scratch

In short: the server should not stop when an error occurs.

Anyone help, please?

Upvotes: 0

Views: 111

Answers (1)

obba
obba

Reputation: 77

If you want NodeJs to start again when its terminated.

Just try to use the process manager program to run your node.

For example PM2

Upvotes: 4

Related Questions