I want to run my node.js server on my linux server (shared hosting) basically indefinitely.
Originally, I've set it up using forever, which worked for a while. But, I've noticed that after around 2 weeks both the forever daemon and the node.js server processes vanish without a trace. No logs whatsoever.
Then, I switched to what I'm currently using - pm2 as a daemon utility. All things were going fine... except they weren't. Pm2 also was shutting down after some time has passed. Infuriated by this, I set up a cron job that basically restarts the pm2 with my node.js server. All of the output was being sent to my inbox.
Up until this Monday (15/07/2019) all things were fine. However, on Monday, 16 minutes after midnight something broke. Again. And this is the output of the cron job attempting restart of the server:
[PM2] Spawning PM2 daemon with pm2_home=/home/jwroczyn/.pm2
[PM2] PM2 Successfully daemonized
[PM2][ERROR] Interpreter node does not seem to be available
[PM2] Starting /home/jwroczyn/krzemien/krzemien-api/server.js in fork_mode (1 instance)
[PM2] Done.
┌──────────┬────┬─────────┬──────┬─────┬─────────┬─────────┬────────┬─────┬────────┬──────────┬──────────┐
│ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │
├──────────┼────┼─────────┼──────┼─────┼─────────┼─────────┼────────┼─────┼────────┼──────────┼──────────┤
│ server │ 0 │ 1.0.6 │ fork │ N/A │ errored │ 0 │ 0 │ 0% │ 0 B │ jwroczyn │ disabled │
└──────────┴────┴─────────┴──────┴─────┴─────────┴─────────┴────────┴─────┴──────
Use `pm2 show <id|name>` to get more details about an app
Status: errored.
Which switched to online only because I killed all pm2 processes and restarted the daemon again.
Unfortunately, I didn't save the output of the pm2 show command (basically no useful information whatsoever). However, when I ran pm2 monit, the value of the memory usage by the server was something like %f25 - not exactly number-like.
Not sure, what to make of that memory usage.
I do not know what to do anymore.
I just want to have my node.js server running normally.