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.

    Problems with starting pm2 start mm.sh

    Scheduled Pinned Locked Moved Unsolved Troubleshooting
    27 Posts 7 Posters 15.3k Views 7 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.
    • M Offline
      madoXX
      last edited by

      Hi,

      i made everything link written in this tutorial
      https://github.com/MichMich/MagicMirror/wiki/Auto-Starting-MagicMirror
      but i stack here:

      "
      Starting your MagicMirror with PM2
      Simply start your mirror with the following command:
      pm2 start mm.sh
      You mirror should now boot up and appear on your screen after a few seconds.
      "

      It doesn’t

      when i enter pm2 start mm.sh i receive the following message:

      [PM2] Starting /home/pi/mm.sh in fork_mode (1 instance)
      [PM2] Done.
      ┌──────┬────┬──────┬────────┬───┬─────┬──────────┐
      │ Name │ id │ mode │ status │ ↺ │ cpu │ memory │
      ├──────┼────┼──────┼────────┼───┼─────┼──────────┤
      │ mm │ 0 │ fork │ online │ 0 │ 0% │ 2.8 MB │
      └──────┴────┴──────┴────────┴───┴─────┴──────────┘
      Use pm2 show <id|name> to get more details about an app

      thats it.

      When i reboot i see the Magic Mirror Screen but the Raspi starts always the standard desktop.

      Any suggestions?

      Thank you very much!

      1 Reply Last reply Reply Quote 0
      • CyruS1337C Offline
        CyruS1337 Project Sponsor
        last edited by

        Did you also follow this point:

        Starting PM2 on boat
        To make sure PM2 can do it’s job when (re) booting your operating system, it needs to be started on boot. Luckily, PM2 has a handy helper for this.

        pm2 startup
        PM2 wants to show you a command you need to execute.

        M 1 Reply Last reply Reply Quote 0
        • S Do not disturb
          sdetweil
          last edited by

          @madoXX said in Problems with starting pm2 start mm.sh:

          /home/pi/mm.sh

          what does this file look like? can u copy the content here?

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 0
          • M Offline
            madoXX @CyruS1337
            last edited by

            @CyruS1337 said in Problems with starting pm2 start mm.sh:

            Did you also follow this point:

            Starting PM2 on boat
            To make sure PM2 can do it’s job when (re) booting your operating system, it needs to be started on boot. Luckily, PM2 has a handy helper for this.

            pm2 startup
            PM2 wants to show you a command you need to execute.

            Thanks for your reply. For the moment i want to know why it doesn’t even start, when i try to start it manually.

            Moreover, here the content of the file mm.sh (saved in /home/pi)

            cd ~/MagicMirror
            DISPLAY=:0 npm start

            S 1 Reply Last reply Reply Quote 0
            • S Do not disturb
              sdetweil @madoXX
              last edited by

              @madoXX said in Problems with starting pm2 start mm.sh:

              cd ~/MagicMirror

              change that 1st line to be

              cd /home/pi/MagicMirror
              

              pm2 is running under root at the time of startup

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              M 1 Reply Last reply Reply Quote 0
              • M Offline
                madoXX @sdetweil
                last edited by

                @sdetweil said in Problems with starting pm2 start mm.sh:

                @madoXX said in Problems with starting pm2 start mm.sh:

                cd ~/MagicMirror

                change that 1st line to be

                cd /home/pi/MagicMirror
                

                pm2 is running under root at the time of startup

                changed it, saved and made a reboot. nothing changed.

                when i write pm2 start i receive the following message:

                [PM2][ERROR] File ecosystem.config.js not found
                ┌──────────┬────┬─────────┬──────┬─────┬────────┬─────────┬────────┬─────┬──────────┬──────┬──────────┐
                │ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │
                ├──────────┼────┼─────────┼──────┼─────┼────────┼─────────┼────────┼─────┼──────────┼──────┼──────────┤
                │ mm │ 0 │ N/A │ fork │ 838 │ online │ 0 │ 3m │ 0% │ 2.4 MB │ pi │ disabled │
                └──────────┴────┴─────────┴──────┴─────┴────────┴─────────┴────────┴─────┴──────────┴──────┴──────────┘
                Use pm2 show <id|name> to get more details about an app

                S 1 Reply Last reply Reply Quote 0
                • S Do not disturb
                  sdetweil @madoXX
                  last edited by sdetweil

                  @madoXX said in Problems with starting pm2 start mm.sh:

                  File ecosystem.config.js not found

                  ok, seems pm2 is not setup right

                  1st make sure script works
                  is it executable?
                  chmod +x mm.sh

                  /home/pi/mm.sh &
                  (and stop it)
                  then 
                  
                  pm2 remove 0
                  pm2 startup
                     this will return a command u need to execute (cut/paste)
                  pm2 start /home/pi/mm.sh
                  pm2 save
                  

                  then

                  pm2 list
                  

                  nothing running

                  pm2 start mm
                  

                  should start ok

                  reboot

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

                  1 Reply Last reply Reply Quote 0
                  • M Offline
                    madoXX
                    last edited by

                    @sdetweil said in Problems with starting pm2 start mm.sh:

                    1st make sure script works
                    is it executable?
                    chmod +x mm.sh

                    ok, done

                    @sdetweil said in Problems with starting pm2 start mm.sh:

                    /home/pi/mm.sh &
                    (and stop it)
                    then

                    don’t get this…
                    should i enter
                    pm2 stop /home/pi/mm.sh &

                    @sdetweil said in Problems with starting pm2 start mm.sh:

                    pm2 remove 0

                    when i enter this, this appears:
                    [PM2] Command not found

                    usage: pm2 [options]

                    pm2 -h, --help all available commands and options
                    pm2 examples display pm2 usage examples
                    pm2 -h help on a specific command

                    Access pm2 files in ~/.pm2
                    [1]+ Fertig pm2 stop /home/pi/mm.sh

                    @sdetweil said in Problems with starting pm2 start mm.sh:

                    pm2 startup
                    ok, had to enter this one:
                    sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi

                    After the enter this one appeared:
                    [PM2] Init System found: systemd
                    Platform systemd
                    Template
                    [Unit]
                    Description=PM2 process manager
                    Documentation=https://pm2.keymetrics.io/
                    After=network.target

                    [Service]
                    Type=forking
                    User=pi
                    LimitNOFILE=infinity
                    LimitNPROC=infinity
                    LimitCORE=infinity
                    Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/usr/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
                    Environment=PM2_HOME=/home/pi/.pm2
                    PIDFile=/home/pi/.pm2/pm2.pid
                    Restart=on-failure

                    ExecStart=/usr/lib/node_modules/pm2/bin/pm2 resurrect
                    ExecReload=/usr/lib/node_modules/pm2/bin/pm2 reload all
                    ExecStop=/usr/lib/node_modules/pm2/bin/pm2 kill

                    [Install]
                    WantedBy=multi-user.target

                    Target path
                    /etc/systemd/system/pm2-pi.service
                    Command list
                    [ ‘systemctl enable pm2-pi’ ]
                    [PM2] Writing init configuration in /etc/systemd/system/pm2-pi.service
                    [PM2] Making script booting at startup…

                    Executing: systemctl enable pm2-pi…

                    [PM2] [v] Command successfully executed.
                    ±--------------------------------------+
                    [PM2] Freeze a process list on reboot via:
                    $ pm2 save

                    [PM2] Remove init script via:
                    $ pm2 unstartup systemd

                    @sdetweil said in Problems with starting pm2 start mm.sh:

                    pm2 start /home/pi/mm.sh

                    here this is the result:
                    [PM2] Applying action restartProcessId on app [mm](ids: 0)
                    [PM2] mm ✓
                    [PM2] Process successfully started
                    ┌──────────┬────┬─────────┬──────┬───────┬────────┬─────────┬────────┬─────┬──────────┬──────┬──────────┐
                    │ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │
                    ├──────────┼────┼─────────┼──────┼───────┼────────┼─────────┼────────┼─────┼──────────┼──────┼──────────┤
                    │ mm │ 0 │ N/A │ fork │ 15797 │ online │ 0 │ 0s │ 0% │ 2.4 MB │ pi │ disabled │
                    └──────────┴────┴─────────┴──────┴───────┴────────┴─────────┴────────┴─────┴──────────┴──────┴──────────┘
                    Use pm2 show <id|name> to get more details about an app

                    @sdetweil said in Problems with starting pm2 start mm.sh:

                    pm2 save

                    Result
                    [PM2] Saving current process list…
                    [PM2] Successfully saved in /home/pi/.pm2/dump.pm2

                    @sdetweil said in Problems with starting pm2 start mm.sh:

                    pm2 list

                    nothing running

                    Yes there is the mm running:
                    ┌──────────┬────┬─────────┬──────┬───────┬────────┬─────────┬────────┬─────┬──────────┬──────┬──────────┐
                    │ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │
                    ├──────────┼────┼─────────┼──────┼───────┼────────┼─────────┼────────┼─────┼──────────┼──────┼──────────┤
                    │ mm │ 0 │ N/A │ fork │ 15797 │ online │ 0 │ 103s │ 0% │ 2.4 MB │ pi │ disabled │
                    └──────────┴────┴─────────┴──────┴───────┴────────┴─────────┴────────┴─────┴──────────┴──────┴──────────┘
                    Use pm2 show <id|name> to get more details about an app

                    @sdetweil said in Problems with starting pm2 start mm.sh:

                    pm2 start mm

                    should start ok

                    perhaps no…
                    [PM2] Applying action restartProcessId on app [mm](ids: 0)
                    [PM2] mm ✓
                    [PM2] Process successfully started
                    ┌──────────┬────┬─────────┬──────┬───────┬────────┬─────────┬────────┬─────┬──────────┬──────┬──────────┐
                    │ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │
                    ├──────────┼────┼─────────┼──────┼───────┼────────┼─────────┼────────┼─────┼──────────┼──────┼──────────┤
                    │ mm │ 0 │ N/A │ fork │ 16995 │ online │ 1 │ 0s │ 0% │ 2.5 MB │ pi │ disabled │
                    └──────────┴────┴─────────┴──────┴───────┴────────┴─────────┴────────┴─────┴──────────┴──────┴──────────┘
                    Use pm2 show <id|name> to get more details about an app

                    Thanks anyway for your help!

                    S 1 Reply Last reply Reply Quote 0
                    • S Do not disturb
                      sdetweil @madoXX
                      last edited by

                      @madoXX does it restart on boot?

                      pm2 remove 0
                      should have been
                      pm2 delete 0

                      and yep, needed a stop after the pm2 save

                      Sam

                      How to add modules

                      learning how to use browser developers window for css changes

                      M 1 Reply Last reply Reply Quote 0
                      • M Offline
                        madoXX @sdetweil
                        last edited by

                        @sdetweil said in Problems with starting pm2 start mm.sh:

                        @madoXX does it restart on boot?

                        pm2 remove 0
                        should have been
                        pm2 delete 0

                        and yep, needed a stop after the pm2 save

                        no, the boot menu from the magic mirror appears (booting up), no error but it goes straight to the desktop.

                        something strang here

                        @sdetweil said in Problems with starting pm2 start mm.sh:

                        then
                        pm2 list

                        nothing running

                        In fact the themm.sh is running caus i startet it above

                        @sdetweil said in Problems with starting pm2 start mm.sh:

                        pm2 start /home/pi/mm.sh

                        D 1 Reply Last reply Reply Quote 0
                        • M Offline
                          madoXX
                          last edited by

                          OK command back…

                          after a few reboots now everything is starting fine.
                          A big thanks to the community here!
                          Very helpfull people here!

                          1 Reply Last reply Reply Quote 0
                          • G Offline
                            Gomalley
                            last edited by

                            I’m actually having thus EXACT problem and it is very frusterating. Im having a little trouble reading all of the instructions to fix it. Did you get yours fixed? If so exactly what did you do to fix it?

                            S 1 Reply Last reply Reply Quote 0
                            • S Do not disturb
                              sdetweil @Gomalley
                              last edited by

                              @Gomalley pm2 runs a script,
                              installers/mm.sh

                              It should read

                              cd /home/pi/MagicMirror
                              ...etc
                              

                              Change it if not.

                              Then

                              pm2 restart 0
                              

                              Sam

                              How to add modules

                              learning how to use browser developers window for css changes

                              1 Reply Last reply Reply Quote 0
                              • G Offline
                                Gomalley
                                last edited by

                                I tried it but I do not think that it worked. My code before I touched it read

                                cd ~/MagicMirror
                                

                                Now i tried two things both gave same output

                                cd ~/home/pi/MagicMirror
                                

                                and

                                cd /home/pi/MagicMirror
                                

                                It now says
                                [PM2] Spawning PM2 daemon with pm2_home=/home/pi/.pm2
                                [PM2] PM2 Successfully daemonized
                                Use --update-env to update environment variables
                                [PM2] Applying action restartProcessId on app [0](ids: [ ‘0’ ])
                                [PM2] [ERROR] Process 0 not found

                                In my mm.sh the file currently reads this:
                                cd /home/pi/MagicMirror
                                DISPLAY=:0 npm start

                                1 Reply Last reply Reply Quote 0
                                • G Offline
                                  Gomalley
                                  last edited by

                                  And I tried restarting the pi and the “Booting up” MagicMirror2 showed but it never actually loaded.

                                  S 1 Reply Last reply Reply Quote 0
                                  • S Do not disturb
                                    sdetweil @Gomalley
                                    last edited by

                                    @Gomalley ok

                                    pm2 list
                                    

                                    If nothing

                                    pm2 start installers/mm.sh
                                    pm2 save
                                    

                                    Sam

                                    How to add modules

                                    learning how to use browser developers window for css changes

                                    1 Reply Last reply Reply Quote 0
                                    • D Offline
                                      Detto65 @madoXX
                                      last edited by

                                      @madoXX
                                      just did a fresh install of my magicmirror, because the sd card went corrupt.
                                      during the install procedure it somehwere asked me if i want to autostart MagicMirror.
                                      after that it started automatically after booting into the desktop first.
                                      When trying to use pm2, it shows me the process is already running, but it’s name is MagicMirror , not mm.
                                      MagicMirror version 2.8.0

                                      S 1 Reply Last reply Reply Quote 0
                                      • S Do not disturb
                                        sdetweil @Detto65
                                        last edited by

                                        @Detto65 yes, the install script uses a json file to configure the pm2 process

                                        Sam

                                        How to add modules

                                        learning how to use browser developers window for css changes

                                        1 Reply Last reply Reply Quote 0
                                        • G Offline
                                          Gomalley
                                          last edited by

                                          When i do

                                          pm2 list
                                          

                                          The "name, id, mode, status, cpu, and memory chart shows up. It is all in blue.
                                          Below it, it says “use ‘pm2 show <id/name>~ to get more details about an app.’”

                                          When i type in

                                          pm2 start
                                          

                                          The same chart above displays along with a message saying
                                          [PM2] [ERROR] File ecosystem.config.js is not found

                                          What does this mean?

                                          1 Reply Last reply Reply Quote 0
                                          • R Offline
                                            Raksasas
                                            last edited by Raksasas

                                            I am having the same problem: I did what was mentioned above and after the reboot it stll did not start automaticly. Running “pm2 list” after the reboot shows mm.sh is not runnning.

                                            permitted by applicable law.
                                            Last login: Sun Jul 28 20:48:49 2019
                                            pi@magicmirror:~ $ pm2 list
                                            [PM2] Spawning PM2 daemon with pm2_home=/home/pi/.pm2
                                            [PM2] PM2 Successfully daemonized
                                            ┌──────────┬────┬─────────┬──────┬─────┬────────┬─────────┬────────┬─────┬─────┬──────┬──────────┐
                                            │ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │
                                            └──────────┴────┴─────────┴──────┴─────┴────────┴─────────┴────────┴─────┴─────┴──────┴──────────┘
                                             Use `pm2 show <id|name>` to get more details about an app
                                            pi@magicmirror:~ $ pm2 start installers/mm.sh
                                            [PM2][ERROR] script not found : /home/pi/installers/mm.sh
                                            script not found : /home/pi/installers/mm.sh
                                            ┌──────────┬────┬─────────┬──────┬─────┬────────┬─────────┬────────┬─────┬─────┬──────┬──────────┐
                                            │ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │
                                            └──────────┴────┴─────────┴──────┴─────┴────────┴─────────┴────────┴─────┴─────┴──────┴──────────┘
                                             Use `pm2 show <id|name>` to get more details about an app
                                            pi@magicmirror:~ $ pm2 start mm.sh
                                            [PM2] Starting /home/pi/mm.sh in fork_mode (1 instance)
                                            [PM2] Done.
                                            ┌──────────┬────┬─────────┬──────┬─────┬────────┬─────────┬────────┬─────┬──────────┬──────┬──────────┐
                                            │ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ cpu │ mem      │ user │ watching │
                                            ├──────────┼────┼─────────┼──────┼─────┼────────┼─────────┼────────┼─────┼──────────┼──────┼──────────┤
                                            │ mm       │ 0  │ N/A     │ fork │ 718 │ online │ 0       │ 0s     │ 0%  │ 2.6 MB   │ pi   │ disabled │
                                            └──────────┴────┴─────────┴──────┴─────┴────────┴─────────┴────────┴─────┴──────────┴──────┴──────────┘
                                             Use `pm2 show <id|name>` to get more details about an app
                                            pi@magicmirror:~ $ pm2 save
                                            [PM2] Saving current process list...
                                            [PM2] Successfully saved in /home/pi/.pm2/dump.pm2
                                            pi@magicmirror:~ $ pm2 list
                                            ┌──────────┬────┬─────────┬──────┬─────┬────────┬─────────┬────────┬─────┬──────────┬──────┬──────────┐
                                            │ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ cpu │ mem      │ user │ watching │
                                            ├──────────┼────┼─────────┼──────┼─────┼────────┼─────────┼────────┼─────┼──────────┼──────┼──────────┤
                                            │ mm       │ 0  │ N/A     │ fork │ 718 │ online │ 0       │ 44s    │ 0%  │ 2.6 MB   │ pi   │ disabled │
                                            └──────────┴────┴─────────┴──────┴─────┴────────┴─────────┴────────┴─────┴──────────┴──────┴──────────┘
                                             Use `pm2 show <id|name>` to get more details about an app
                                            pi@magicmirror:~ $ pm2 save
                                            [PM2] Saving current process list...
                                            [PM2] Successfully saved in /home/pi/.pm2/dump.pm2
                                            pi@magicmirror:~ $ sudo reboot
                                            Connection to 192.168.138.28 closed by remote host.
                                            Connection to 192.168.138.28 closed.
                                            
                                            
                                            pi@magicmirror:~ $ cat mm.sh
                                            cd /home/pi/MagicMirror
                                            DISPLAY=:0 npm start
                                            pi@magicmirror:~ $ ls -lha mm.sh
                                            -rwxr-xr-x 1 pi pi 45 Jul 28 20:14 mm.sh
                                            pi@magicmirror:~ $ 
                                            
                                            
                                            S 1 Reply Last reply Reply Quote 0

                                            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                            With your input, this post could be even better 💗

                                            Register Login
                                            • 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