Read the statement by Michael Teeuw here.
Can't get pm2 to auto launch after reboot
-
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 startupNow 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.shNow start up Magic Mirror and make it start up on boot:
pm2 start mm.shpm2 save
Now, reboot your Pi by typing in
sudo reboot -
@gmgarcia719 said in Can't get pm2 to auto launch after reboot:
pm2 start mm.sh
pm2 saveinstead try
pm2 start mmpm2 save
ejay
-
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 saveYou 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
-
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.pidIf the file does not exist you can create it with:
sudo pm2 startup systemd -u piBut you need to check the values again after creating it.
In the end you can enable the script with:
sudo systemd enable pm2-pi.serviceThe parts in described by @Chris are needed as well
