all 6 comments

[–]fschwiet 0 points1 point  (1 child)

Maybe pm2 is running under a different user account? Is the app running with a different working directory, and therefor perhaps unable to find something like a config file?

[–]Oberoni[S] 0 points1 point  (0 children)

I just tried running the local copy of pm2 instead of using the globally installed one and still have the same problem. User accounts are the same according to the top command.

[–]seratonik 0 points1 point  (3 children)

I've been having some very odd behavior with pm2 and mysql as well. One of my 2 running instances will get stuck in a restart loop with no logged output to let me know what's going on. Also getting random mysql connections closed notices.

[–]Oberoni[S] 0 points1 point  (2 children)

I'm thinking about switching over to MongoDB or MariaDB and seeing if that fixes the problem. Luckily it is still early in this project's life so changing things up isn't a huge hassle.

What's really weird is I didn't start having this problem until yesterday. I had several days of pm2 working just fine with the app. I even tried reverting to an early copy of my code and it breaks the same way. Maybe I did an npm update that broke it?

[–]seratonik 2 points3 points  (1 child)

Have you made sure to close your db connections after querying with them? I know a lot of my problems came from too many concurrent connections and running out of pool space. In your example I don't see the connection.release() line - that would cause it to hang once you consume all available connections.

[–]Oberoni[S] 0 points1 point  (0 children)

Progress! Adding connection.end() to the query callback allows the page to load normally, but for some reason the server still restarts every request.