MagicMirror² v2.14.0 is available! For more information about this release, check out this topic.

stopping MM via pm2 does not close electron - at restart I get EADDRINUSE

  • Hey there,

    always after restarting I get an error EADDRINUSE. To investigate I looked at `netstat -lptn’ to see which program uses what port.
    At startup I see only one line coresponding to MM which is this:

    tcp        1      0  *               LISTEN      1019/electron.js

    But when I use `pm2 stop mm’ I still see this line. I also tried to change the port for each restart with the result of having multiple instances of electron listening on the coresponding ports.
    When starting it manually without pm2 in the console it opens and closes correctly after quitting.
    Has anyone a guess how to solve this?

  • some additional information: when running fine, pm2 seems to be the parent process:

      612 ?        Ssl    0:34 PM2 v3.1.3: God Daemon (/home/pi/.pm2)
      797 ?        Ss     0:00  \_ bash /home/pi/MagicMirror/installers/
      799 ?        Sl     0:04      \_ npm
      946 ?        S      0:00          \_ sh -c sh
      947 ?        S      0:00              \_ sh
      949 ?        Sl     0:01                  \_ node /home/pi/MagicMirror/node_modules/.bin/electron js/electron.js
      958 ?        Sl     8:43                      \_ /home/pi/MagicMirror/node_modules/electron/dist/electron js/electron.js
      960 ?        S      0:00                          \_ /home/pi/MagicMirror/node_modules/electron/dist/electron --type=zygote --no-sandbox
     1088 ?        Sl     4:50                          |   \_ /home/pi/MagicMirror/node_modules/electron/dist/electron --type=renderer --no-sandbox --service-pipe-token=756DBD94487A30A46611ABEDF5588C31 --
     1087 ?        Sl     0:05                          \_ /home/pi/MagicMirror/node_modules/electron/dist/electron --type=gpu-process --no-sandbox --supports-dual-gpus=false --gpu-driver-bug-workarounds=9

    but as soon as I stop MM in pm2 I see 2 different parent processes:

      612 ?        Ssl    0:34 PM2 v3.1.3: God Daemon (/home/pi/.pm2)
      958 ?        Sl     8:45 /home/pi/MagicMirror/node_modules/electron/dist/electron js/electron.js
      960 ?        S      0:00  \_ /home/pi/MagicMirror/node_modules/electron/dist/electron --type=zygote --no-sandbox
     1088 ?        Sl     4:51  |   \_ /home/pi/MagicMirror/node_modules/electron/dist/electron --type=renderer --no-sandbox --service-pipe-token=756DBD94487A30A46611ABEDF5588C31 --lang=de --app-path=/home
     1087 ?        Sl     0:05  \_ /home/pi/MagicMirror/node_modules/electron/dist/electron --type=gpu-process --no-sandbox --supports-dual-gpus=false --gpu-driver-bug-workarounds=9,27,84 --disable-gl-exte

    so pm2 is still running, but left the electron browser also running now without a parent.

  • Project Sponsor

    It sounds like something on your Pi is attempting to start the Magic Mirror process twice. If you used a cron job to start MM as well as PM2, then this can happen. Likewise, if your script that PM2 calls to start the process has the command twice, this can happen.

    EADDRINUSE usually means that two processes are trying to serve up web pages on the same port. If that happens on reboot, then most likely two commands are trying to start MM.

    My recommendation is to remove PM2’s attempts to start MM, reboot and see if the mirror process starts. If so, find out how it’s being called and remove that, then reset pm2 to do it. If MM doesn’t start after the reboot, run your netstat -lptn again and find out what’s listening on that port.

Log in to reply