I am working with raspberry pi os lite on raspberry pi 4.
I wanted to autostart a Qt application.
I created under /etc/systemd/system
a .service file named application_one.service
this is what the .service file looks like
[Unit]
Description=Qt application autostart
After=graphical.target
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=pi
WorkingDirectory=/home/pi/a
ExecStart=/home/pi/a/test_v1 -platform linuxfb
[Install]
WantedBy=multi-user.target
after that I enabled this service
sudo systemctl enable application_one.service
but it couldn't autostart the apllication after rebooting
when I do sudo systemctl start application_one.service
it works fine
these ares the status
sudo systemctl status application_one.service
●くろまる application_one.service - Qt application autostart
Loaded: loaded (/etc/systemd/system/application_one.service; enabled; vendor
Active: inactive (dead)
when booting I have 2 messages before splashscreen
[ 3.005162] systemd[1] : multi-user.target : Job application_one.service/start deleted to break ordering cycle starting with multi-user.target/start
[ 3.005162] systemd[1] : multi-user.target : Job application_one.service/start
lti-user.target/start
this is what my splashscreen.service looks like :
[Unit]
Description=Splash screen
DefaultDependencies=no
After=local-fs.target
[Service]
ExecStart=/usr/bin/fbi -d /dev/fb0 --noverbose -a /home/pi/image.png
StandardInput=tty
StandardOutput=tty
[Install]
WantedBy=sysinit.target
Can some please explain to me what I am doing wrong
thank you
1 Answer 1
You created a configuration which is impossible to resolve:
application_one.service
must start aftergraphical.target
(G before A)graphical.target
requiresmulti-user.target
(M before G)multi-user.target
wants to startapplication_one.service
(A before M)
One way to break the loop would be swapping the order in which the units load. For instance you have now put After=multi-user.target
and WantedBy=graphical.target
in your unit file. Your service will start after multi-user.target
, but only if graphical.target
is about to load. If you want to make sure the GUI is ready when your app is about to load, you may actually want to specify e.g. After=lightdm.target
instead of multi-user
.
-
1Thank you I just verified the order with
systemd-analyze critical-chain
you are right ! but removingWantedBy=multi-user.target
didn't fix the problem because when I tried to enable the service an error showed upThe unit files have no installation config (WantedBy=, RequiredBy=, Also=, Alias= settings in the [Install] section, and DefaultInstance= for template units). This means they are not meant to be enabled using systemctl.
so I just swapped the two elements :After=multi-user.target
WantedBy= graphical.target
. Thank you for helpingmina– mina2021年02月23日 15:16:40 +00:00Commented Feb 23, 2021 at 15:16 -
1the strange thing is that I used this configuration like 2 mounths ago interelectronix.com/fr/… and it worked I don't know howmina– mina2021年02月23日 15:17:45 +00:00Commented Feb 23, 2021 at 15:17
-
1@mina Thanks for reporting the issue, I will fix my answer.Dmitry Grigoryev– Dmitry Grigoryev2021年02月24日 10:20:54 +00:00Commented Feb 24, 2021 at 10:20
-
3@mina That it works some times and then suddenly no more is respected to the asynchronous (parallel) working of systemd. A very little change in timing to start the services will break the running order if no dependencies set.Ingo– Ingo2021年02月24日 10:29:04 +00:00Commented Feb 24, 2021 at 10:29
-
I think I follow most of your explanation, but one question: Is
lightdm.target
not included in the Lite distro? I run my systems on the Lite distro, and I have nolightdm.target
. I do however, have agraphical.target
, but no graphics obviously.Seamus– Seamus2022年01月06日 09:17:23 +00:00Commented Jan 6, 2022 at 9:17
Explore related questions
See similar questions with these tags.
systemctl status application_one.service
and add its complete output including CGroup: lines and latest log messages to the question. You use a Qt application that is a GUI library and want to start it after the graphical target. So I assume you are running an application with a graphical user interface. Why do you need a GUI by running/home/pi/a/test_v1
as service continous in the background? Services do not have a user interface.sudo systemctl status application_one.service ●くろまる application_one.service - Qt application autostart Loaded: loaded (/etc/systemd/system/application_one.service; enabled; vendor Active: inactive (dead) lines 1-3/3 (END)
this all what I gottest_v1
is just an exactable of my Qt application that I want to start. is there an other way to autostart it without using a service?