sdetweil / MagicMirror_scripts

Magic Mirror installation and setup scripts
357 stars 62 forks source link

Not starting automatically on boot on pi4 #9

Closed rejas closed 4 years ago

rejas commented 4 years ago

Hi @sdetweil tried to freshly install with your scripts on my new pi4, alas they dont manage to make the mirror software start automatically on bootup. pm2 entry is generated so once the pi is up a pm2 start MagicMirror works. The install.log looks at the end like this:

...
Dependencies installation Done!
fixing sandbox permissions
setting up initial config.js
Check plymouth installation ...
Splashscreen: Checking themes directory.
Splashscreen: Create theme directory if not exists.
Splashscreen: Changed theme to MagicMirror successfully.
install and setup pm2
pm2 not installed, installing
pm2 install result /usr/local/bin/pm2 -> /usr/local/lib/node_modules/pm2/bin/pm2 /usr/local/bin/pm2-dev -> /usr/local/lib/node_modules/pm2/bin/pm2-dev /usr/local/bin/pm2-docker -> /usr/local/lib/node_modules/pm2/bin/pm2-docker /usr/local/bin/pm2-runtime -> /usr/local/lib/node_modules/pm2/bin/pm2-runtime npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/pm2/node_modules/chokidar/node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm"}) + pm2@4.4.0 added 270 packages from 214 contributors in 40.331s
get the pm2 platform specific startup command
startup command = sudo env PATH=$PATH:/usr/bin:/bin /usr/local/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi

                        -------------

__/\\\\\\\\\\\\\____/\\\\____________/\\\\____/\\\\\\\\\_____
 _\/\\\/////////\\\_\/\\\\\\________/\\\\\\__/\\\///////\\\___
  _\/\\\_______\/\\\_\/\\\//\\\____/\\\//\\\_\///______\//\\\__
   _\/\\\\\\\\\\\\\/__\/\\\\///\\\/\\\/_\/\\\___________/\\\/___
    _\/\\\/////////____\/\\\__\///\\\/___\/\\\________/\\\//_____
     _\/\\\_____________\/\\\____\///_____\/\\\_____/\\\//________
      _\/\\\_____________\/\\\_____________\/\\\___/\\\/___________
       _\/\\\_____________\/\\\_____________\/\\\__/\\\\\\\\\\\\\\\_
        _\///______________\///______________\///__\///////////////__

                          Runtime Edition

        PM2 is a Production Process Manager for Node.js applications
                     with a built-in Load Balancer.

                Start and Daemonize any application:
                $ pm2 start app.js

                Load Balance 4 instances of api.js:
                $ pm2 start api.js -i 4

                Monitor in production:
                $ pm2 monitor

                Make pm2 auto-boot at server restart:
                $ pm2 startup

                To go further checkout:
                http://pm2.io/

                        -------------

[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=$PATH:/usr/bin:/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/local/lib/node_modules/pm2/bin/pm2 resurrect
ExecReload=/usr/local/lib/node_modules/pm2/bin/pm2 reload all
ExecStop=/usr/local/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...
[PM2] [-] 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
pm2 startup command done
configure the pm2 config file for MagicMirror
start MagicMirror via pm2 now
save MagicMirror pm2 config now
stop MagicMirror via pm2 now
disable screensaver via gsettings was true and uint32 300
disable screensaver via lightdm.conf
disable screensaver via lxsession
We're ready! Run pm2 start MagicMirror from the ~/MagicMirror directory to start your MagicMirror.
install completed - Fr Mai 29 22:05:05 CEST 2020
sdetweil commented 4 years ago

was mm running when u rebooted? what OS version are u running? that info is at the top of the log?

i haven't burned a new sd card to test with since March.. (testing with buster at that time)

rejas commented 4 years ago
sdetweil commented 4 years ago

and if its running now before reboot?

at the request of a couple users i added a stmt to the installer to close the first run MM to allow the user to get back to the commandline.. this may have impacted the pm2 startup results..

from the very top of the log

install starting  - Sun Mar 22 09:01:14 CDT 2020
installing on x86_64 processor system
the os is Distributor ID: Ubuntu Description: Ubuntu 18.04.4 LTS Release: 18.04 Codename: bionic
rejas commented 4 years ago

If its running now and then I reboot, it doesnt start up. It was a fresh install, so there wasnt any MM installed or running on the pi.

install starting  - Fr Mai 29 21:48:22 CEST 2020
installing on armv7l processor system
the os is Distributor ID: Raspbian Description: Raspbian GNU/Linux 10 (buster) Release: 10 Codename: buster
rejas commented 4 years ago

Where would one manually add the autostart code/routine in the system? Maybe there is something different if raspbian is runnign on a pi4.

sdetweil commented 4 years ago

i just tested on my odroid, and now testing on my pi..

the pm2 setup for autostart is to do pm2 startup it will give you the command to do the setup

can u show the output of pm2 logs --lines=200 those files are also in the ~/.pm2/logs folder my pi4 just booted with new install and pm2 setup and MM started on 1st boot..

can u run the fixuppm2 script from here and see if it makes a difference?

rejas commented 4 years ago

The fixuppm2 script helped. Now it starts on bootup too. Thx.