I'm trying to run a python GUI application as a service. The application is using PyQt5 and python-vlc packages. I have the following service file:
[Unit]
Description="Python VLC Service Test"
After=multi-user.target
[Service]
Type=simple
User=pi
Environment="DISPLAY=:0"
Environment="XAUTHORITY=/home/pi/.Xauthority"
ExecStart=/usr/bin/python3 /opt/experimental/vlc_pyqt.py
Restart=on-failure
[Install]
WantedBy=graphical.target
However, when playing video in the vlc window, only white screen shows up. After looking in journalctl
I found these two errors:
Aug 18 16:26:27 raspberrypi python3[17754]: [83ab02c8] dbus_screensaver inhibit error: cannot connect to session bus: Failed to connect to socket /tmp/dbus-ZeiFpFnTZO: Connection refused
Aug 18 16:26:33 raspberrypi python3[17754]: [84f28b10] mmal_codec filter error: Failed to alloc CMA buf: fmt=Z420, size=3133440
I think the CMA buffer error is a result of the first one. Any ideas how to fix it? The application is running just fine when run directly (not as a service).
I would like to run it as a service in order to be able to monitor the status of the application via systemctl status vlc_pyqt.service
as the application should run all the time on the machine and to be able to gracefully restart it by systemctl restart vlc_pyqt.service
if needed.
:0
doesn't belong topi
before anyone logs in (running a service as a specific user does not involve a login) -- although why it opens the app at all then I dunno.pi
user when testing this. I tried to runsudo systemctl --user start vlc_test.service
but gotAug 23 18:52:51 raspberrypi systemd[574]: vlc_test.service: Failed with result 'exit-code'
. Any ideas how to fix this? I could not find anything explaining what could have gone wrongsystemclt status ...
may give a bit more information. There's kind of a pseudo/semi XY problem here, in that it's hard to see why you want to run this as a service. If it's because you want it to run at boot, this is probably a bad method; you should use autostart via the DE. If you are trying to get it to run at boot, then it seems completely pointless.systemctl status vlc_pyqt.service
as the application should run all the time on the machine and be able to gracefully restart it bysystemctl restart vlc_pyqt.service
if needed. I will add it the explanation the question. Regarding logging:systemctl status
showed only the last few messages and no more thanjournalctl
I mentioned in the question. Those two errors do not happen when I run it the standard way. I will post a complete log from the vlc in a few hours.