NPM process dies
Everything is working fine but I have a persistent issue that I can’t seem to fix. Whether I start NPM manually from a terminal or NPM starting automatically with a script, it seems to die randomly. The RPI3 is still up, just NPM dies. Are there logs that I take a look at to see what’s causing it?
For the time being, I’m using crontab to reboot every couple of hours but I’d like to avoid that if possible.
If you install PM2 per the instructions, it will automatically get restarted if/when it dies.
As for why it dies, if you are running PM2, you might be able to see if anything gets logged with
'pm2 logs'. But I’m not sure if it does log anything to be honest. PM2 does, but the npm process itself … unsure.
Thanks, this helps!
@KirAsh4 Yes, I bought the CanaKit 5V 2.5A Raspberry Pi 3 Power Supply
Other than a potential file system corruption, or faulty memory on the rpi itself, I can’t think of anything else that could be killing the process. While rather rare, I have seen brand new rpis have faulty memory. You’d have to install and run
'memtester'to check the memory. If that checks out, you can check the file system itself with
'fsck'. WARNING: doing this on a running system can cause issues. However, since the rpi runs off of the card, it’s unable to unmount the card, so you have two choices:
a) schedule a file system check at the next reboot:
$ sudo touch /forcefsck $ sudo reboot
b) alternatively, you can force a file system check while it’s running:
$ sudo fsck -fy /dev/mmcblk0p2 $ sudo reboot
'mmcblk0p2'listed above you get by typing in
'mount'and looking at the line that shows the root file system on, denoted by a single
$ mount /dev/mmcblk0p2 on / type ext4 (rw,noatime,data=ordered) <============================= THAT LINE devtmpfs on /dev type devtmpfs (rw,relatime,size=469540k,nr_inodes=117385,mode=755) sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime) proc on /proc type proc (rw,relatime) ...
And if it found errors, you can only hope that the
fsckfixed them, otherwise you’re looking at either a system rebuild (where you start fresh, by burning a new image to the card and go through all the steps to configure the rpi and reinstall everything), or possibly even replacing the card as well (in which case you’re going to go through a rebuild anyways, so you may as well do that.)
@KirAsh4 Thanks again. I ran memtester and everything was reported ok. I’m now going to use forcefsck and see what it finds.
@KirAsh4 Deployed PM2, and works as described. Thanks!
Glad that’s working. It still doesn’t solve the fact that it’s dying on you, but at least it will restart it automatically for you. I think my process dies at least once a week or so … totally random, with the pi doing nothing.