Answer the question
In order to leave comments, you need to log in
How to restart nodejs locally?
There is a local server on nodejs, sometimes errors fly out on it, i.e. the server itself works fine, it doesn't crash, but after that I need to restart it so that the endpoint works fine. Is there any way to restart the server automatically? I thought to organize the process as follows:
1. If an error occurs on the front, we send a request to a separate endpoint.
2. On the node on this endpoint, I will put the restart command and that's it.
The project is local and in development, so you can shaman anything. Just to restart. Is it possible to organize this?
Answer the question
In order to leave comments, you need to log in
IMHO, in case of errors, it is better to write a flag to some known directory and, for example, periodically check the presence of this flag by cron. If there is a file, reboot the server and delete the file.
"standard" script
while true do node index.js >> errors.log; sleep 5; done
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question