An alternate (and better) method to start ppup1090 at boot is to create ppup1090.service file and enable it, so that ppup1090 is started by systemd instead of rc.local.
This method has following advantages:
- It makes starting of
ppup1090 to wait till dump1090-fa, or dump1090-mutability starts.
- The user can control & monitor
ppup1090 by systemctl commands.
The systemd method given below completely replaces following item of Post #1:
“(3) Make ppup1090 to auto-start at boot”
NOTE:
If you have already implemented rc.local startup of Post #1, and want to switch to systemd startup given below, first disable the rc.local startup by following steps:
(1) Open file rc.local to edit
sudo nano /etc/rc.local
(2) From the file opened, delete following line:
/home/pi/ppup/ppup-maint.sh &
(3) Save (Ctrl+o) and Close (Ctrl+x)
(4) Reboot RPi
sudo reboot
.
STEP BY STEP METHOD FOR STARTUP BY SYSTEMD
1 - Create system user ppup1090 which will start the service automatically at boot.
sudo useradd --system ppup1090
.
2 - Create a blank file ppup1090.service in folder /lib/systemd/system/ppup1090.service
sudo nano /lib/systemd/system/ppup1090.service
.
3 - Copy-paste following code in this blank file
Note-1: following 2 versions of code are identical, except for the line starting with After=
Note-2: Noted that systemd-journal continously runs & generates plane upload log. To overcome this and reduce cpu & memory usage, I have added --quiet at end of the line ExecStart=/home/pi/ppup/ppup1090.
`
.
IF USING DUMP1090-FA
Applies to:
- Piaware SD Card image (which has
dump1090-fa pre-installed).
- Raspbian image with
dump1090-fa package install.
# planeplotter uploader service for systemd
# create in /lib/systemd/system/
# then install in /etc/systemd/system/default.target.wants/
# by command: sudo systemctl enable ppup1090.service
[Unit]
Description=PlanePlotter Raspberry Pi uploader
Wants=network-online.target
After=dump1090-fa.service network-online.target time-sync.target
[Service]
User=ppup1090
RuntimeDirectory=ppup
ExecStart=/home/pi/ppup/ppup1090 --quiet
ExecReload=/bin/kill -HUP $MAINPID
Type=simple
Restart=on-failure
RestartSec=30
# exit code 4 means login failed
# exit code 6 means startup failed
RestartPreventExitStatus=4 6
[Install]
WantedBy=default.target
Save (Ctrl+o) and close (Ctrl+x)
.
IF USING DUMP1090-MUTABILITY
Applies to:
- Raspbian image with
dump1090-mutability ver 1.15~dev package install
- PI24 image (which has
dump1090-mutability ver 1.14 pre-installed)
# planeplotter uploader service for systemd
# create in /lib/systemd/system/
# then install in /etc/systemd/system/default.target.wants/
# by command: sudo systemctl enable ppup1090.service
[Unit]
Description=PlanePlotter Raspberry Pi uploader
Wants=network-online.target
After=dump1090-mutability.service network-online.target time-sync.target
[Service]
User=ppup1090
RuntimeDirectory=ppup
ExecStart=/home/pi/ppup/ppup1090 --quiet
ExecReload=/bin/kill -HUP $MAINPID
Type=simple
Restart=on-failure
RestartSec=30
# exit code 4 means login failed
# exit code 6 means startup failed
RestartPreventExitStatus=4 6
[Install]
WantedBy=default.target
Save (Ctrl+o) and close (Ctrl+x)
.
4 - Enable service by following command
sudo systemctl enable ppup1090.service
sudo systemctl restart ppup1090
.
5 - Check status after few minutes
pi@raspberrypi:~ $ sudo systemctl status ppup1090
● ppup1090.service - PlanePlotter Raspberry Pi uploader
Loaded: loaded (/lib/systemd/system/ppup1090.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2019-03-17 04:36:59 EDT; 5min ago
Main PID: 860 (ppup1090)
CGroup: /system.slice/ppup1090.service
└─860 /home/pi/ppup/ppup1090 --quiet
Mar 17 04:36:59 raspberrypi systemd[1]: Started PlanePlotter Raspberry Pi uploader.
.
6 - Commands to control & monitor
sudo systemctl restart ppup1090
sudo systemctl stop ppup1090
sudo systemctl status ppup1090
.