I have a Debian stretch on RPI. I need to start a custom service on boot up.
/lib/systemd/system/lora-packet-forwarder.service
Service is enabled, but shows up as inactive
lora-packet-forwarder.service - LoRa Packet Forwarder
Loaded: loaded (/lib/systemd/system/lora-packet-forwarder.service; enabled; vendor preset: enabled)
Active: inactive (dead)
Checking:
sudo journalctl -f -u lora-packet-forwarder.service
-- shows up nothing
If I start it manually from console, it works fine:
sudo systemctl start lora-packet-forwarder.service
lora-packet-forwarder.service - LoRa Packet Forwarder
Loaded: loaded (/lib/systemd/system/lora-packet-forwarder.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2019-07-05 15:01:48 BST; 3s ago
Process: 554 ExecStartPre=/home/pi/lora_gateway/reset_lgw.sh start (code=exited, status=0/SUCCESS)
Main PID: 570 (lora_pkt_fwd)
Memory: 568.0K
CGroup: /system.slice/lora-packet-forwarder.service
└─570 /home/pi/packet_forwarder/lora_pkt_fwd/lora_pkt_fwd
Jul 05 15:01:47 raspberrypi systemd[1]: Starting LoRa Packet Forwarder...
Jul 05 15:01:47 raspberrypi reset_lgw.sh[554]: Accessing concentrator reset pin through GPIO25...
Jul 05 15:01:48 raspberrypi systemd[1]: Started LoRa Packet Forwarder.
Here are the contents of the service file:
[Unit]
Description=LoRa Packet Forwarder
[Service]
WorkingDirectory=/home/pi/packet_forwarder/lora_pkt_fwd
ExecStartPre=/home/pi/packet_forwarder/lora_pkt_fwd/reset_lgw.sh start
ExecStart=/home/pi/packet_forwarder/lora_pkt_fwd/lora_pkt_fwd
[Install]
WantedBy=multi-user.target
I have a small shell script to reset the GPIO pin, before the lora_pkt_fwd is launched. Here are the permissions for both files:
-rwxr-xr-x 1 pi pi 1485 Jul 3 21:38 reset_lgw.sh
-rwxr-xr-x 1 pi pi 144680 Jul 3 20:17 lora_pkt_fwd
Regarding the settings, have tried already:
- put "bash" for shell script -
ExecStartPre=bash /home/pi/packet_forwarder/lora_pkt_fwd/reset_lgw.sh start
- Tried combinations of After=network.target, Before=network-online.target, Wants=network-online.target in [Unit] section
- Tried Type=simple and forking in [Service] section
- Tries disable/enable the service and daemon-reload (just in case)
I could get this done with cron task or something , but I want to do it right.
systemctl enable lora-packet-forwarder.service
?systemctl status lora-packet-forwarder.service
right after bootup, oncesystemctl list-jobs
is already empty.