• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
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.

Can't get pm2 to auto launch after reboot

Scheduled Pinned Locked Moved Unsolved Troubleshooting
4 Posts 4 Posters 1.6k Views 3 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.
  • G Offline
    gmgarcia719
    last edited by Mar 9, 2019, 8:38 AM

    I’ve Done all of the below steps bit it till wont auto launch when i reboot the PI

    We want Magic Mirror to start up automatically, so type in the following command:
    pm2 startup

    Now create a shell script for startup. Open up the built-in text editor on the Pi by typing in:
    cd ~
    nano mm.sh
    The lower line basically means, “open up a file called mm.sh in the nano text editor.”

    When the text editor has opened, add this to the mm.sh file:
    cd ~/MagicMirror
    DISPLAY=:0 npm start
    Exit the editor by pressing ctrl+x and type in y to save the file.

    Make your shiny new script executable by typing in:
    chmod +x mm.sh

    Now start up Magic Mirror and make it start up on boot:
    pm2 start mm.sh

    pm2 save

    Now, reboot your Pi by typing in
    sudo reboot

    E 1 Reply Last reply Mar 9, 2019, 9:24 AM Reply Quote 0
    • E Offline
      ejay-ibm Project Sponsor Module Developer @gmgarcia719
      last edited by Mar 9, 2019, 9:24 AM

      @gmgarcia719 said in Can't get pm2 to auto launch after reboot:

      pm2 start mm.sh
      pm2 save

      instead try
      pm2 start mm

      pm2 save

      ejay

      1 Reply Last reply Reply Quote 0
      • C Offline
        Chris
        last edited by Mar 9, 2019, 9:30 AM

        Hello,
        test this:

        there is an existing script provided by MagicMirror now, please try deleting everything on your ~/.pm2 directory, then using:

        sudo su -c "env PATH=$PATH:/usr/bin pm2 startup linux -u pi --hp /home/pi"
            pm2 start ~/MagicMirror/installers/pm2_MagicMirror.json
            pm2 save
        

        You may have to use systemd instead of linux in the first line if you get an error.

        This solution is not mine but Shbatm.

        See this post: Here

        cordially

        1 Reply Last reply Reply Quote 1
        • W Offline
          wishmaster270 Module Developer
          last edited by Mar 9, 2019, 9:37 AM

          Hi,
          i had the same problem the last weeks.
          It looks like pm2 creates the startup script for systemd with wrong parameters.
          You should check if there exists a file “/etc/systemd/systemd/pm2-pi.service”
          In my case the file existed but contained the following lines:

          USER=root which should be USER=pi
          Environment=PM2_HOME=/root/.pm2 which should be Environment=PM2_HOME=/home/pi/.pm2
          PIDFile=/root/.pm2/pm2.pid which should be PIDFile=/home/pi/.pm2/pm2.pid

          If the file does not exist you can create it with:
          sudo pm2 startup systemd -u pi

          But you need to check the values again after creating it.
          In the end you can enable the script with:
          sudo systemd enable pm2-pi.service

          The parts in described by @Chris are needed as well

          1 Reply Last reply Reply Quote 1
          • 1 / 1
          1 / 1
          • First post
            3/4
            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