1

From time to time it does happen, but restarting the node bypass this. I really don't have how to debug and see the actual error and the site needs to be online anyway.

I wish to know a way to restart the server whet this error happens, without having to change a file or anything like that.

I know this is a way around, etc etc... but that's what I need to do now...

ERROR:

[nodemon] app crashed - waiting for file changes before starting...

PACKAGE.json

 "scripts": {
            "test": "echo \"Error: no test specified\" && exit 1",
            "start": "node app.js",
            "server": "nodemon app --ignore './client/'",
            "client": "npm start --prefix client",
            "dev": "concurrently \"npm run server\" \"npm run client\"",
            "build": "concurrently \"npm run server\" \"npm run client\""
        },

starting using node server.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Datafinder
  • 37
  • 1
  • 5
  • If you have not done it already, review answers for https://stackoverflow.com/questions/37486631/nodemon-app-crashed-waiting-for-file-changes-before-starting – PM 77-1 Mar 22 '22 at 16:38
  • “*I know this is a way around, etc etc... but that's what I need to do now...*” Can you elaborate as to why this is the imperative, as opposed to investing the same time into actually fixing the cause of the crash itself? What you’re asking for is bound to lead to data integrity issues, horrendous UXs, oversized/polluted log files… etc. depending on your program’s use case. – esqew Mar 22 '22 at 16:49
  • @PM77-1 Thanks. I checked it! – Datafinder Mar 24 '22 at 14:10
  • @esqew Im not a react developer, but I have a good experience in developing other languages and infrastructure. My actual developer is not avaiable anymore and I'm trying to do my best to keep the app up and running. I already spent lots of time trying to solve this but I couldn't. – Datafinder Mar 24 '22 at 14:13

2 Answers2

0

This occurred because the process was exited in a non-graceful way. If you want auto-restart after crashing, that's not the purpose of nodemon.

I would recommend pm2

Jone Polvora
  • 2,184
  • 1
  • 22
  • 33
  • Jone, this is recomended to ans PRODUCTION environment right? I Mean, even if I change something, the application shouldn't restart without a window of downtime. The NODEMON is used for DEV? My questions is about best practices here. – Datafinder Mar 24 '22 at 14:02
0

You could try using forever as advised in the nodemon FAQ.

forever -c "nodemon --exitcrash" app.js

This way if the script crashes, forever restarts the script, and if there are file changes, nodemon restarts your script.

Wyck
  • 10,311
  • 6
  • 39
  • 60
  • Full disclosure: that last line of my answer is excerpted from the FAQ verbatim. – Wyck Mar 22 '22 at 16:55
  • Wyck, thanks for the answer. Actually, I spent yesterday trying to make it work wiht the joint of PM2(I dont want to loose the web interface to do something from anywere easy) and FOREVER on the same command. The problem is that I develop on a windows machine and the server is on LINUX. The command line which works on the linux does not on windows. – Datafinder Mar 24 '22 at 14:05
  • Using today on package.js: "server": "nodemon app --ignore './client/'" – Datafinder Mar 24 '22 at 14:06
  • try to use a diferent line for linux call: "server_linux": "forever start -d -v -f -a -l forever.log -c 'nodemon --exitcrash' app.js" But the application keeps on restarting. If I do this command directly on windows, it works. – Datafinder Mar 24 '22 at 14:07
  • The PM2 : pm2 start "npm run server_linux" -l /var/log/pm2.log --name server – Datafinder Mar 24 '22 at 14:09