I have a python application that I need to be launched on Ubuntu startup
I would like also that application to be launched again if it closes/crashes.
That is something that Systemd can handle, but the problem is that my application open a window with the camera streaming.
Because of that, a systemd service throw errors:
nov 21 19:42:54 Xavier-AGX env[14289]: 2021-11-21 19:42:54,558 Connected to mysql server: X.X.X.X
nov 21 19:42:55 Xavier-AGX env[14289]: qt.qpa.xcb: could not connect to display
nov 21 19:42:55 Xavier-AGX env[14289]: qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/atc/.local/lib/python3.6/site-packages/cv2/qt/plugins" even though it was found.
nov 21 19:42:55 Xavier-AGX env[14289]: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
nov 21 19:42:55 Xavier-AGX env[14289]: Available platform plugins are: xcb.
nov 21 19:42:56 Xavier-AGX systemd[1]: app_cam0.service: Main process exited, code=dumped, status=6/ABRT
nov 21 19:42:56 Xavier-AGX systemd[1]: app_cam0.service: Failed with result 'core-dump'.
nov 21 19:42:57 Xavier-AGX systemd[1]: app_cam0.service: Service hold-off time over, scheduling restart.
nov 21 19:42:57 Xavier-AGX systemd[1]: app_cam0.service: Scheduled restart job, restart counter is at 3.
nov 21 19:42:57 Xavier-AGX systemd[1]: Stopped Service to launch the app (Camera 0).
nov 21 19:42:57 Xavier-AGX systemd[1]: Started Service to launch the app (Camera 0).
An alternative is to use CRON. There is a flag (@reboot), that makes CRON run your app at boot time, but in case the app crashes, it will not launch it again. :(
So, what can I do ?
Is there any solution to run a GUI app as a systemd service?
Thanks in advance.