I'm running a couple scripts to drive a dot matrix display on boot of a Pi 3 B. A nodejs script just writes an image file to a path. The python script calls Adafruit_RGBmatrix to send the image to the display. The nodejs runs fine at boot. The python script can crash the entire pi when run at boot, but it runs fine when started manually with systemctl.

python: dashboard.py

import Image
import time
from rgbmatrix import Adafruit_RGBmatrix

# Rows and chain length are both required parameters:
matrix = Adafruit_RGBmatrix(32, 2)


while True:
    image = Image.open("/home/pi/dashboard.png")
    matrix.SetImage(image.im.id, 0, 0)
    print("Dashboard image could not be opened!")

systemd dashboard_display.service

Description=Dashboard Display Driver

ExecStart=/usr/bin/python /home/pi/src/drive-display/dashboard.py


When I run the dashboard_display.service using systemctl start dashboard_display.service it runs for days. Running it at boot after enable, it crashes the pi somewhow.

I've tried to set up some delays on reboot and have tried various After and Require values. Also wrapped the python script in a try/except to allow it to sleep and retry.

I don't get logs but it seems like it's failing extremely fast too many times and the pi crashes.

Is there a better way to ensure these services get started when everything is available? And the python service won't start until the nodejs service is done?

  • 1. where exactly does that script "crash". You should be able to add a few prints there to see where it "crashes". 2. when you run systemd, then journald should be also running. You can make the journald journals persistent accross reboots and then look at the logs to see what happend before your machine crashed (and you had to reboot it...) – Tomáš Pospíšek Mar 15 '20 at 22:22
  • Can you please include output of systemctl status dashboard_display.service after boot? Also look at journalctl -b -u dashboard_display.service for the logs since last boot. If your home directory is on a separate partition, you might need RequiresMountsFor=/home to ensure that partition is mounted before systemd tries to start the service. – filbranden Mar 15 '20 at 23:21

Some information is missing in your question, but I am assuming the commented-out #Requires=dashboard_png.service is the nodejs script that suppose to create dashboard.png file. Also, missing the description of the "crash" I can only assume it is being caused by either dashpoard.png not being there at all, or being written by the nodejs while pythin is trying to read from it.

Having made those two assumptions, I would suggest trying to add After=dashboard_png.service to the [Unit] part of the dashboard_display.service, and uncommenting the Requires=dashboard_png.service.

According to the systemd.unit manual:

requirement dependencies do not influence the order in which services are started or stopped. This has to be configured independently with the After= or Before= options. If unit foo.service pulls in unit bar.service as configured with Wants= and no ordering is configured with After= or Before=, then both units will be started simultaneously and without any delay between them if foo.service is activated.

Although the quote is taken from the description of Wants= directive, the same applies to the Requires= directive as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.