MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    pm2 do not work after v2.8.0 Update

    Scheduled Pinned Locked Moved Solved Troubleshooting
    12 Posts 6 Posters 4.8k Views 5 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K Offline
      Klinge
      last edited by Klinge

      Hello,

      I installed a new MM and I got a problem with automatic start with pm2.
      I take a freshly installed Raspbian Buster and installed the MM on it. The option of automatic start over pm2 I confirmed with “y”. After the installation, the MM also started automatically.
      But when I restart the Pi now, the MM does not start automatically anymore. When I enter “pm2 status”, no application will appear. Of course, I try to start the MM via “pm2 start MagicMirror”. But it also fails. Although pm2 shows the application MagicMirror with the status “online”, but the MM does not start. “pm2 logs MagicMirror” gives the following problem

      /home/pi/.pm2/logs/MagicMirror-error.log last 15 lines:
      0|MagicMir | { Error: ENOENT: no such file or directory, open 'package.json'
      0|MagicMir | at Object.openSync (fs.js:443:3)
      0|MagicMir | at Object.readFileSync (fs.js:343:35)
      0|MagicMir | at Object.<anonymous> (/home/pi/MagicMirror/js/app.js:15:32)
      0|MagicMir | at Module._compile (internal/modules/cjs/loader.js:776:30)
      0|MagicMir | at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
      0|MagicMir | at Module.load (internal/modules/cjs/loader.js:653:32)
      0|MagicMir | at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
      0|MagicMir | at Function.Module._load (internal/modules/cjs/loader.js:585:3)
      0|MagicMir | at Module.require (internal/modules/cjs/loader.js:690:17)
      0|MagicMir | at Module.Hook._require.Module.require (/usr/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:70:37)
      0|MagicMir | errno: -2,
      0|MagicMir | syscall: 'open',
      0|MagicMir | code: 'ENOENT',
      0|MagicMir | path: 'package.json' }
      

      The MM suddenly has a problem with the package.json file.

      From the directory … \ MagicMirror I can start the MM manually via “npm start”. But of course I need the automatic start.

      It would be really great if anyone could help me.
      Thanks in advance

      1 Reply Last reply Reply Quote 0
      • S Offline
        sdetweil @Klinge
        last edited by

        @Klinge cool!.. thanks for the feedback

        pm2 startup should have told you to execute another command. right?

        on my system

        odroid@odroid:~/MagicMirror$ pm2 startup
        [PM2] Init System found: systemd
        [PM2] **To setup the Startup Script, copy/paste the following command:**
        sudo env PATH=$PATH:/usr/bin /usr/local/lib/node_modules/pm2/bin/pm2 startup systemd -u odroid --hp  /home/odroid
        

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        1 Reply Last reply Reply Quote 0
        • L Offline
          lukas1760
          last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • bheplerB Offline
            bhepler Module Developer
            last edited by bhepler

            All right, let’s get you fixed up.

            If I understand you properly, when you type pm2 status all you get something akin to this:

            ┌─────────────┬────┬──────┬─────┬────────┬─────────┬────────┬─────┬──────────┬──────┬──────────┐
            │ App name    │ id │ mode │ pid │ status │ restart │ uptime │ cpu │ mem      │ user │ watching │
            ├─────────────┼────┼──────┼─────┼────────┼─────────┼────────┼─────┼──────────┼──────┼──────────┤
            
            └─────────────┴────┴──────┴─────┴────────┴─────────┴────────┴─────┴──────────┴──────┴──────────┘
            

            Assuming that this is the case, it sounds like pm2 needs to start watching your magic mirror process again. Clear out your pm2 logs by typing pm2 flush. You should be able to re-engage pm2 on the MagicMirror script like so: pm2 start /home/pi/MagicMirror/installers/mm.sh. After it loads your mirror, save the state of pm2 by typing pm2 save.

            Give that a go and report back please.

            1 Reply Last reply Reply Quote 0
            • K Offline
              Klinge
              last edited by Klinge

              Thank you for your help.

              But unfortunately it doesn´t work.

              I cleared the logfiles and started the MM as you described. The MM also started. And so I saved the state. But after I restarted the Pi, the MM did not start automatically anymore.

              PM2 status was empty

              pi@raspberrypi:~ $ pm2 status
              [PM2] Spawning PM2 daemon with pm2_home=/home/pi/.pm2
              [PM2] PM2 Successfully daemonized
              ┌──────┬────┬──────┬────────┬───┬─────┬────────┐
              │ Name │ id │ mode │ status │ ↺ │ cpu │ memory │
              └──────┴────┴──────┴────────┴───┴─────┴────────┘
               Use `pm2 show <id|name>` to get more details about an app
              
              
              S 1 Reply Last reply Reply Quote 0
              • S Offline
                sdetweil @Klinge
                last edited by

                @Klinge interesting error reported similar behavior

                https://github.com/Unitech/pm2/issues/2006

                if node or npm versions change, may need to rerun

                pm2 startup
                

                command

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                1 Reply Last reply Reply Quote 0
                • K Offline
                  Klinge
                  last edited by Klinge

                  Thank you for your advice.

                  What exactly did I do?

                  I installed npm again with

                  sudo npm install -g pm2 
                  

                  Then I entered

                  pm2 startup
                  pm2 start /home/pi/MagicMirror/installers/mm.sh 
                  

                  Der MM startete. And then

                  sudo pm2 flush
                  pm2 flush
                  pm2 save
                  sudo pm2 save
                  

                  And when I restart the PI, MM start automatically.

                  I do not know exactly what helped. But it works.

                  Thank you again :-)

                  S bheplerB 2 Replies Last reply Reply Quote 0
                  • S Offline
                    sdetweil @Klinge
                    last edited by

                    @Klinge cool!.. thanks for the feedback

                    pm2 startup should have told you to execute another command. right?

                    on my system

                    odroid@odroid:~/MagicMirror$ pm2 startup
                    [PM2] Init System found: systemd
                    [PM2] **To setup the Startup Script, copy/paste the following command:**
                    sudo env PATH=$PATH:/usr/bin /usr/local/lib/node_modules/pm2/bin/pm2 startup systemd -u odroid --hp  /home/odroid
                    

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    1 Reply Last reply Reply Quote 0
                    • bheplerB Offline
                      bhepler Module Developer @Klinge
                      last edited by

                      @Klinge said in pm2 do not work after v2.8.0 Update:

                      Then I entered

                      pm2 startup
                      pm2 start /MagicMirror/installers/mm.sh 
                      

                      This path is wrong.

                      1 Reply Last reply Reply Quote 0
                      • K Offline
                        Klinge
                        last edited by Klinge

                        @sdetweil Yes, you are right

                        on my sytem it was

                        sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi
                        
                        

                        @bhepler Yes, you are right too.

                        My path above was relative, not absolute. But of course, it was wrong. I entered the absolute path. So I have improved it above :-)

                        1 Reply Last reply Reply Quote 0
                        • I Offline
                          Ivanov_d
                          last edited by Ivanov_d

                          I do have the same issue and although I managed to make MM start automatically I now have two instances and one restarts every few seconds because of the same error:

                          0|MagicMirror  | { Error: ENOENT: no such file or directory, open 'package.json'
                          0|MagicMirror  |     at Object.openSync (fs.js:443:3)
                          0|MagicMirror  |     at Object.readFileSync (fs.js:343:35)
                          0|MagicMirror  |     at Object.<anonymous> (/home/pi/MagicMirror/js/app.js:15:32)
                          0|MagicMirror  |     at Module._compile (internal/modules/cjs/loader.js:776:30)
                          0|MagicMirror  |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
                          0|MagicMirror  |     at Module.load (internal/modules/cjs/loader.js:653:32)
                          0|MagicMirror  |     at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
                          0|MagicMirror  |     at Function.Module._load (internal/modules/cjs/loader.js:585:3)
                          0|MagicMirror  |     at Module.require (internal/modules/cjs/loader.js:690:17)
                          0|MagicMirror  |     at Module.Hook._require.Module.require (/usr/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:70:37)
                          0|MagicMirror  |   errno: -2,
                          0|MagicMirror  |   syscall: 'open',
                          0|MagicMirror  |   code: 'ENOENT',
                          0|MagicMirror  |   path: 'package.json' }
                          PM2            | App [MagicMirror:0] exited with code [1] via signal [SIGINT]
                          PM2            | App [MagicMirror:0] starting in -fork mode-
                          PM2            | App [MagicMirror:0] online
                          
                          
                          pi@raspberrypi:~ $ pm2 status all
                          ┌─────────────┬────┬─────────┬──────┬──────┬────────┬─────────┬────────┬─────┬───────────┬──────┬──────────┐
                          │ App name    │ id │ version │ mode │ pid  │ status │ restart │ uptime │ cpu │ mem       │ user │ watching │
                          ├─────────────┼────┼─────────┼──────┼──────┼────────┼─────────┼────────┼─────┼───────────┼──────┼──────────┤
                          │ MagicMirror │ 0  │ 2.8.0   │ fork │ 2096 │ online │ 87      │ 1s     │ 0%  │ 30.9 MB   │ pi   │ disabled │
                          │ mm          │ 1  │ 2.8.0   │ fork │ 914  │ online │ 0       │ 3m     │ 0%  │ 2.5 MB    │ pi   │ disabled │
                          └─────────────┴────┴─────────┴──────┴──────┴────────┴─────────┴────────┴─────┴───────────┴──────┴──────────┘
                           Use `pm2 show <id|name>` to get more details about an app
                          
                          

                          How do I:
                          a) fix MagicMirror startup script
                          or
                          b) make it stop from auto starting (e.g. stopping it manually via pm2 stop MagicMirror and then saving the state with pm2 save doesn’t work)

                          S F 2 Replies Last reply Reply Quote 0
                          • 1
                          • 2
                          • 1 / 2
                          • First post
                            Last post
                          Enjoying MagicMirror? Please consider a donation!
                          MagicMirror created by Michael Teeuw.
                          Forum managed by Sam, technical setup by Karsten.
                          This forum is using NodeBB as its core | Contributors
                          Contact | Privacy Policy