systemd service run when using requires/after

The name of the pictureThe name of the pictureThe name of the pictureClash 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?










share|improve this question























  • 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














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?










share|improve this question























  • 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












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?










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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
















  • 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















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















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



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














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













































































Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)