Hi,
I am running Raspbian Lite on a RPi and trying to get systemd to start a graphical python app. The weird thing is I can enter 2 commands into terminal and get my graphical app to run but the same commands in systemd unit file does not work! It seems the unit file is running but my ExecStart is failing.
In the folder /etc/systemd/system I have a file called kegwasher.service which looks like this:
[Unit]
Description=Keg Washer
[Service]
User=pi
Environment=DISPLAY=:0
ExecStart=/bin/bash /home/pi/appstart & startx
Restart=always
RestartSec=20s
KillMode=process
TimeoutSec=infinity
[Install]
WantedBy=graphical.target
In the folder /home/pi I have a file called "appstart" which looks like this:
#! /bin/bash
sleep 1
sudo chvt 1
python3 /home/pi/KegWasher.py
Here are the results from typing "sudo systemctl status kegwasher.service":
kegwasher.service - Keg Washer
Loaded: loaded (etc/systemd/system/kegwasher.service; ...............)
Active: activating (auto-restart) (Result: exit-code)
Process: 527 ExecStart=/bin/bash /home/pi/appstart & startx (code-exited, status=1/FAILURE
My graphical python app works perfectly (and my appstart script works) by typing the following commands into terminal:
export DISPLAY=:0
/home/pi/appstart & startx
Some tutorials said I needed to perform the command "sudo chmod +x appstart" and to perform "sudo chmod 644 kegwasher.service" but I still get FAILURE.
To test I am running "sudo systemctl daemon-reload" and then "sudo systemctl start kegwasher.service" but my only result is FAILURE.
Can anyone tell me what I am doing wrong?
I am running Raspbian Lite on a RPi and trying to get systemd to start a graphical python app. The weird thing is I can enter 2 commands into terminal and get my graphical app to run but the same commands in systemd unit file does not work! It seems the unit file is running but my ExecStart is failing.
In the folder /etc/systemd/system I have a file called kegwasher.service which looks like this:
[Unit]
Description=Keg Washer
[Service]
User=pi
Environment=DISPLAY=:0
ExecStart=/bin/bash /home/pi/appstart & startx
Restart=always
RestartSec=20s
KillMode=process
TimeoutSec=infinity
[Install]
WantedBy=graphical.target
In the folder /home/pi I have a file called "appstart" which looks like this:
#! /bin/bash
sleep 1
sudo chvt 1
python3 /home/pi/KegWasher.py
Here are the results from typing "sudo systemctl status kegwasher.service":
kegwasher.service - Keg Washer
Loaded: loaded (etc/systemd/system/kegwasher.service; ...............)
Active: activating (auto-restart) (Result: exit-code)
Process: 527 ExecStart=/bin/bash /home/pi/appstart & startx (code-exited, status=1/FAILURE
My graphical python app works perfectly (and my appstart script works) by typing the following commands into terminal:
export DISPLAY=:0
/home/pi/appstart & startx
Some tutorials said I needed to perform the command "sudo chmod +x appstart" and to perform "sudo chmod 644 kegwasher.service" but I still get FAILURE.
To test I am running "sudo systemctl daemon-reload" and then "sudo systemctl start kegwasher.service" but my only result is FAILURE.
Can anyone tell me what I am doing wrong?
Last edited: