systemd service run when using requires/after

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have two services :
First starts X, it is /etc/systemd/system/startx@.service
[Unit]
Description=startx automatique pour l'utilisateur %I
After=graphical.target systemd-user-sessions.service
[Service]
User=%I
Environment=XAUTHORITY=/tmp/.Xauthority_%I
PAMName=login
Type=simple
ExecStart=/bin/bash -l -c startx
[Install]
WantedBy=graphical.target
Second one, app.service requires X to be running as it uses display :0.0
[Unit]
Description=mY service
Requires= serviceA serviceB
After= serviceA serviceB
[Service]
Environment=DISPLAY=:0.0
User=USER_NAME
ExecStart=/bin/bash -c "my_app params ..."
Restart=always
[Install]
WantedBy=multi-user.target
When enabling both services
systemctl enable startx@remi.service
systemctl enable my_app.service
X server is started, my_app is started, its windows are displayed.
After, in order to prevent my_app to be started when X server not yet started
I added :
Requires=serviceA serviceB startx@remi.service
After=serviceA serviceB startx@remi.service
to app.service.
I disabled units, rebooted and tested modif with :
systemctl start my_app.service
X server is started, my_app is started, its windows are displayed.
Then I enabled app.service :
on next boot, X is started but my_app is not started. After some tests, I can see X is often started (not always), serviceA, serviceB are always started and my_app is never started.
Here is critical chain for startx :
systemd-analyze critical-chain startx@remi.service
The time after the unit is active or started is printed after the "@" character.
The time the unit takes to start is printed after the "+" character.
startx@remi.service @5.296s
âÂÂâÂÂgraphical.target @5.293s
âÂÂâÂÂmulti-user.target @5.292s
âÂÂâÂÂgetty.target @5.292s
âÂÂâÂÂgetty@tty1.service @5.267s
âÂÂâÂÂsystemd-user-sessions.service @5.221s +36ms
âÂÂâÂÂnetwork.target @5.214s
âÂÂâÂÂnetctl-auto@wlan1.service @4.195s +1.013s
âÂÂâÂÂbasic.target @4.096s
âÂÂâÂÂsockets.target @4.091s
âÂÂâÂÂdbus.socket @4.086s
âÂÂâÂÂsysinit.target @4.067s
âÂÂâÂÂhaveged.service @3.982s +74ms
âÂÂâÂÂsystemd-tmpfiles-setup.service @3.854s +96ms
âÂÂâÂÂsystemd-journal-flush.service @3.557s +284ms
âÂÂâÂÂvar-log.mount @3.474s +64ms
âÂÂâÂÂlocal-fs-pre.target @3.436s
âÂÂâÂÂlvm2-monitor.service @1.214s +2.098s
âÂÂâÂÂlvm2-lvmetad.service @1.434s
âÂÂâÂÂsystemd-journald.socket @1.173s
âÂÂâÂÂ-.mount @649ms
âÂÂâÂÂsystem.slice @649ms
âÂÂâÂÂ-.slice @649ms
And critical chain for my_app :
systemd-analyze critical-chain detect_smile.service
The time after the unit is active or started is printed after the "@" character.
The time the unit takes to start is printed after the "+" character.
âÂÂâÂÂstartx@remi.service @5.296s
âÂÂâÂÂgraphical.target @5.293s
âÂÂâÂÂmulti-user.target @5.292s
âÂÂâÂÂgetty.target @5.292s
âÂÂâÂÂgetty@tty1.service @5.267s
âÂÂâÂÂsystemd-user-sessions.service @5.221s +36ms
âÂÂâÂÂnetwork.target @5.214s
âÂÂâÂÂnetctl-auto@wlan1.service @4.195s +1.013s
âÂÂâÂÂbasic.target @4.096s
âÂÂâÂÂsockets.target @4.091s
âÂÂâÂÂdbus.socket @4.086s
âÂÂâÂÂsysinit.target @4.067s
âÂÂâÂÂhaveged.service @3.982s +74ms
âÂÂâÂÂsystemd-tmpfiles-setup.service @3.854s +96ms
âÂÂâÂÂsystemd-journal-flush.service @3.557s +284ms
âÂÂâÂÂvar-log.mount @3.474s +64ms
âÂÂâÂÂlocal-fs-pre.target @3.436s
âÂÂâÂÂlvm2-monitor.service @1.214s +2.098s
âÂÂâÂÂlvm2-lvmetad.service @1.434s
âÂÂâÂÂsystemd-journald.socket @1.173s
âÂÂâÂÂ-.mount @649ms
âÂÂâÂÂsystem.slice @649ms
âÂÂâÂÂ-.slice @649ms
As you can see, my_app service is not shown above startx@remi.service
Why?
systemd x
add a comment |Â
up vote
0
down vote
favorite
I have two services :
First starts X, it is /etc/systemd/system/startx@.service
[Unit]
Description=startx automatique pour l'utilisateur %I
After=graphical.target systemd-user-sessions.service
[Service]
User=%I
Environment=XAUTHORITY=/tmp/.Xauthority_%I
PAMName=login
Type=simple
ExecStart=/bin/bash -l -c startx
[Install]
WantedBy=graphical.target
Second one, app.service requires X to be running as it uses display :0.0
[Unit]
Description=mY service
Requires= serviceA serviceB
After= serviceA serviceB
[Service]
Environment=DISPLAY=:0.0
User=USER_NAME
ExecStart=/bin/bash -c "my_app params ..."
Restart=always
[Install]
WantedBy=multi-user.target
When enabling both services
systemctl enable startx@remi.service
systemctl enable my_app.service
X server is started, my_app is started, its windows are displayed.
After, in order to prevent my_app to be started when X server not yet started
I added :
Requires=serviceA serviceB startx@remi.service
After=serviceA serviceB startx@remi.service
to app.service.
I disabled units, rebooted and tested modif with :
systemctl start my_app.service
X server is started, my_app is started, its windows are displayed.
Then I enabled app.service :
on next boot, X is started but my_app is not started. After some tests, I can see X is often started (not always), serviceA, serviceB are always started and my_app is never started.
Here is critical chain for startx :
systemd-analyze critical-chain startx@remi.service
The time after the unit is active or started is printed after the "@" character.
The time the unit takes to start is printed after the "+" character.
startx@remi.service @5.296s
âÂÂâÂÂgraphical.target @5.293s
âÂÂâÂÂmulti-user.target @5.292s
âÂÂâÂÂgetty.target @5.292s
âÂÂâÂÂgetty@tty1.service @5.267s
âÂÂâÂÂsystemd-user-sessions.service @5.221s +36ms
âÂÂâÂÂnetwork.target @5.214s
âÂÂâÂÂnetctl-auto@wlan1.service @4.195s +1.013s
âÂÂâÂÂbasic.target @4.096s
âÂÂâÂÂsockets.target @4.091s
âÂÂâÂÂdbus.socket @4.086s
âÂÂâÂÂsysinit.target @4.067s
âÂÂâÂÂhaveged.service @3.982s +74ms
âÂÂâÂÂsystemd-tmpfiles-setup.service @3.854s +96ms
âÂÂâÂÂsystemd-journal-flush.service @3.557s +284ms
âÂÂâÂÂvar-log.mount @3.474s +64ms
âÂÂâÂÂlocal-fs-pre.target @3.436s
âÂÂâÂÂlvm2-monitor.service @1.214s +2.098s
âÂÂâÂÂlvm2-lvmetad.service @1.434s
âÂÂâÂÂsystemd-journald.socket @1.173s
âÂÂâÂÂ-.mount @649ms
âÂÂâÂÂsystem.slice @649ms
âÂÂâÂÂ-.slice @649ms
And critical chain for my_app :
systemd-analyze critical-chain detect_smile.service
The time after the unit is active or started is printed after the "@" character.
The time the unit takes to start is printed after the "+" character.
âÂÂâÂÂstartx@remi.service @5.296s
âÂÂâÂÂgraphical.target @5.293s
âÂÂâÂÂmulti-user.target @5.292s
âÂÂâÂÂgetty.target @5.292s
âÂÂâÂÂgetty@tty1.service @5.267s
âÂÂâÂÂsystemd-user-sessions.service @5.221s +36ms
âÂÂâÂÂnetwork.target @5.214s
âÂÂâÂÂnetctl-auto@wlan1.service @4.195s +1.013s
âÂÂâÂÂbasic.target @4.096s
âÂÂâÂÂsockets.target @4.091s
âÂÂâÂÂdbus.socket @4.086s
âÂÂâÂÂsysinit.target @4.067s
âÂÂâÂÂhaveged.service @3.982s +74ms
âÂÂâÂÂsystemd-tmpfiles-setup.service @3.854s +96ms
âÂÂâÂÂsystemd-journal-flush.service @3.557s +284ms
âÂÂâÂÂvar-log.mount @3.474s +64ms
âÂÂâÂÂlocal-fs-pre.target @3.436s
âÂÂâÂÂlvm2-monitor.service @1.214s +2.098s
âÂÂâÂÂlvm2-lvmetad.service @1.434s
âÂÂâÂÂsystemd-journald.socket @1.173s
âÂÂâÂÂ-.mount @649ms
âÂÂâÂÂsystem.slice @649ms
âÂÂâÂÂ-.slice @649ms
As you can see, my_app service is not shown above startx@remi.service
Why?
systemd x
Did you look in your logs to find out?
â JdeBP
Aug 28 at 17:41
I've added critical chain as you can see, my_app service is not started at all
â rem
Aug 29 at 8:38
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have two services :
First starts X, it is /etc/systemd/system/startx@.service
[Unit]
Description=startx automatique pour l'utilisateur %I
After=graphical.target systemd-user-sessions.service
[Service]
User=%I
Environment=XAUTHORITY=/tmp/.Xauthority_%I
PAMName=login
Type=simple
ExecStart=/bin/bash -l -c startx
[Install]
WantedBy=graphical.target
Second one, app.service requires X to be running as it uses display :0.0
[Unit]
Description=mY service
Requires= serviceA serviceB
After= serviceA serviceB
[Service]
Environment=DISPLAY=:0.0
User=USER_NAME
ExecStart=/bin/bash -c "my_app params ..."
Restart=always
[Install]
WantedBy=multi-user.target
When enabling both services
systemctl enable startx@remi.service
systemctl enable my_app.service
X server is started, my_app is started, its windows are displayed.
After, in order to prevent my_app to be started when X server not yet started
I added :
Requires=serviceA serviceB startx@remi.service
After=serviceA serviceB startx@remi.service
to app.service.
I disabled units, rebooted and tested modif with :
systemctl start my_app.service
X server is started, my_app is started, its windows are displayed.
Then I enabled app.service :
on next boot, X is started but my_app is not started. After some tests, I can see X is often started (not always), serviceA, serviceB are always started and my_app is never started.
Here is critical chain for startx :
systemd-analyze critical-chain startx@remi.service
The time after the unit is active or started is printed after the "@" character.
The time the unit takes to start is printed after the "+" character.
startx@remi.service @5.296s
âÂÂâÂÂgraphical.target @5.293s
âÂÂâÂÂmulti-user.target @5.292s
âÂÂâÂÂgetty.target @5.292s
âÂÂâÂÂgetty@tty1.service @5.267s
âÂÂâÂÂsystemd-user-sessions.service @5.221s +36ms
âÂÂâÂÂnetwork.target @5.214s
âÂÂâÂÂnetctl-auto@wlan1.service @4.195s +1.013s
âÂÂâÂÂbasic.target @4.096s
âÂÂâÂÂsockets.target @4.091s
âÂÂâÂÂdbus.socket @4.086s
âÂÂâÂÂsysinit.target @4.067s
âÂÂâÂÂhaveged.service @3.982s +74ms
âÂÂâÂÂsystemd-tmpfiles-setup.service @3.854s +96ms
âÂÂâÂÂsystemd-journal-flush.service @3.557s +284ms
âÂÂâÂÂvar-log.mount @3.474s +64ms
âÂÂâÂÂlocal-fs-pre.target @3.436s
âÂÂâÂÂlvm2-monitor.service @1.214s +2.098s
âÂÂâÂÂlvm2-lvmetad.service @1.434s
âÂÂâÂÂsystemd-journald.socket @1.173s
âÂÂâÂÂ-.mount @649ms
âÂÂâÂÂsystem.slice @649ms
âÂÂâÂÂ-.slice @649ms
And critical chain for my_app :
systemd-analyze critical-chain detect_smile.service
The time after the unit is active or started is printed after the "@" character.
The time the unit takes to start is printed after the "+" character.
âÂÂâÂÂstartx@remi.service @5.296s
âÂÂâÂÂgraphical.target @5.293s
âÂÂâÂÂmulti-user.target @5.292s
âÂÂâÂÂgetty.target @5.292s
âÂÂâÂÂgetty@tty1.service @5.267s
âÂÂâÂÂsystemd-user-sessions.service @5.221s +36ms
âÂÂâÂÂnetwork.target @5.214s
âÂÂâÂÂnetctl-auto@wlan1.service @4.195s +1.013s
âÂÂâÂÂbasic.target @4.096s
âÂÂâÂÂsockets.target @4.091s
âÂÂâÂÂdbus.socket @4.086s
âÂÂâÂÂsysinit.target @4.067s
âÂÂâÂÂhaveged.service @3.982s +74ms
âÂÂâÂÂsystemd-tmpfiles-setup.service @3.854s +96ms
âÂÂâÂÂsystemd-journal-flush.service @3.557s +284ms
âÂÂâÂÂvar-log.mount @3.474s +64ms
âÂÂâÂÂlocal-fs-pre.target @3.436s
âÂÂâÂÂlvm2-monitor.service @1.214s +2.098s
âÂÂâÂÂlvm2-lvmetad.service @1.434s
âÂÂâÂÂsystemd-journald.socket @1.173s
âÂÂâÂÂ-.mount @649ms
âÂÂâÂÂsystem.slice @649ms
âÂÂâÂÂ-.slice @649ms
As you can see, my_app service is not shown above startx@remi.service
Why?
systemd x
I have two services :
First starts X, it is /etc/systemd/system/startx@.service
[Unit]
Description=startx automatique pour l'utilisateur %I
After=graphical.target systemd-user-sessions.service
[Service]
User=%I
Environment=XAUTHORITY=/tmp/.Xauthority_%I
PAMName=login
Type=simple
ExecStart=/bin/bash -l -c startx
[Install]
WantedBy=graphical.target
Second one, app.service requires X to be running as it uses display :0.0
[Unit]
Description=mY service
Requires= serviceA serviceB
After= serviceA serviceB
[Service]
Environment=DISPLAY=:0.0
User=USER_NAME
ExecStart=/bin/bash -c "my_app params ..."
Restart=always
[Install]
WantedBy=multi-user.target
When enabling both services
systemctl enable startx@remi.service
systemctl enable my_app.service
X server is started, my_app is started, its windows are displayed.
After, in order to prevent my_app to be started when X server not yet started
I added :
Requires=serviceA serviceB startx@remi.service
After=serviceA serviceB startx@remi.service
to app.service.
I disabled units, rebooted and tested modif with :
systemctl start my_app.service
X server is started, my_app is started, its windows are displayed.
Then I enabled app.service :
on next boot, X is started but my_app is not started. After some tests, I can see X is often started (not always), serviceA, serviceB are always started and my_app is never started.
Here is critical chain for startx :
systemd-analyze critical-chain startx@remi.service
The time after the unit is active or started is printed after the "@" character.
The time the unit takes to start is printed after the "+" character.
startx@remi.service @5.296s
âÂÂâÂÂgraphical.target @5.293s
âÂÂâÂÂmulti-user.target @5.292s
âÂÂâÂÂgetty.target @5.292s
âÂÂâÂÂgetty@tty1.service @5.267s
âÂÂâÂÂsystemd-user-sessions.service @5.221s +36ms
âÂÂâÂÂnetwork.target @5.214s
âÂÂâÂÂnetctl-auto@wlan1.service @4.195s +1.013s
âÂÂâÂÂbasic.target @4.096s
âÂÂâÂÂsockets.target @4.091s
âÂÂâÂÂdbus.socket @4.086s
âÂÂâÂÂsysinit.target @4.067s
âÂÂâÂÂhaveged.service @3.982s +74ms
âÂÂâÂÂsystemd-tmpfiles-setup.service @3.854s +96ms
âÂÂâÂÂsystemd-journal-flush.service @3.557s +284ms
âÂÂâÂÂvar-log.mount @3.474s +64ms
âÂÂâÂÂlocal-fs-pre.target @3.436s
âÂÂâÂÂlvm2-monitor.service @1.214s +2.098s
âÂÂâÂÂlvm2-lvmetad.service @1.434s
âÂÂâÂÂsystemd-journald.socket @1.173s
âÂÂâÂÂ-.mount @649ms
âÂÂâÂÂsystem.slice @649ms
âÂÂâÂÂ-.slice @649ms
And critical chain for my_app :
systemd-analyze critical-chain detect_smile.service
The time after the unit is active or started is printed after the "@" character.
The time the unit takes to start is printed after the "+" character.
âÂÂâÂÂstartx@remi.service @5.296s
âÂÂâÂÂgraphical.target @5.293s
âÂÂâÂÂmulti-user.target @5.292s
âÂÂâÂÂgetty.target @5.292s
âÂÂâÂÂgetty@tty1.service @5.267s
âÂÂâÂÂsystemd-user-sessions.service @5.221s +36ms
âÂÂâÂÂnetwork.target @5.214s
âÂÂâÂÂnetctl-auto@wlan1.service @4.195s +1.013s
âÂÂâÂÂbasic.target @4.096s
âÂÂâÂÂsockets.target @4.091s
âÂÂâÂÂdbus.socket @4.086s
âÂÂâÂÂsysinit.target @4.067s
âÂÂâÂÂhaveged.service @3.982s +74ms
âÂÂâÂÂsystemd-tmpfiles-setup.service @3.854s +96ms
âÂÂâÂÂsystemd-journal-flush.service @3.557s +284ms
âÂÂâÂÂvar-log.mount @3.474s +64ms
âÂÂâÂÂlocal-fs-pre.target @3.436s
âÂÂâÂÂlvm2-monitor.service @1.214s +2.098s
âÂÂâÂÂlvm2-lvmetad.service @1.434s
âÂÂâÂÂsystemd-journald.socket @1.173s
âÂÂâÂÂ-.mount @649ms
âÂÂâÂÂsystem.slice @649ms
âÂÂâÂÂ-.slice @649ms
As you can see, my_app service is not shown above startx@remi.service
Why?
systemd x
systemd x
edited Aug 29 at 8:38
asked Aug 28 at 17:02
rem
15817
15817
Did you look in your logs to find out?
â JdeBP
Aug 28 at 17:41
I've added critical chain as you can see, my_app service is not started at all
â rem
Aug 29 at 8:38
add a comment |Â
Did you look in your logs to find out?
â JdeBP
Aug 28 at 17:41
I've added critical chain as you can see, my_app service is not started at all
â rem
Aug 29 at 8:38
Did you look in your logs to find out?
â JdeBP
Aug 28 at 17:41
Did you look in your logs to find out?
â JdeBP
Aug 28 at 17:41
I've added critical chain as you can see, my_app service is not started at all
â rem
Aug 29 at 8:38
I've added critical chain as you can see, my_app service is not started at all
â rem
Aug 29 at 8:38
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f465348%2fsystemd-service-run-when-using-requires-after%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Did you look in your logs to find out?
â JdeBP
Aug 28 at 17:41
I've added critical chain as you can see, my_app service is not started at all
â rem
Aug 29 at 8:38