[systemd-devel] Issue on Ordering of systemd services during boot

Colin Guthrie gmane at colin.guthr.ie
Tue Dec 10 08:12:00 UTC 2019


I presume B.socket is some kind of network socket rather than filesystem
path? Either that or A.service provides the filesystem for the socket path?

That being the case, you've got an ordering cycle here as B.socket has
WantedBy=sockets.target which is order before multi-user.target which is
needed by A.service.

Take the WantedBy out of the B.socket (and ensure you remove any
symlinks that were created when it was installed/enabled - better to do
"systemctl disable B.socket" before editing the unit!) and replace it
with multi-user.target too (like A.service) and this should remove the
ordering cycle and give more deterministic behaviour.

HTHs

Col


TARANA, YASHASHVI wrote on 10/12/2019 07:07:
> Hi,
> 
>  
> 
> I have a systemd service /A.service/ and socket /B.socket /and its
> corresponding service /B./service with the following content:
> 
>               
> 
>                /A.service/
> 
>                               [Unit]
> 
>                               Description=A.service
> 
>                              
> 
>                               [Service]
> 
>                               ExecStart=/root/test start
> 
>                               RemainAfterExit=true
> 
>                               ExecStop=/root/test stop
> 
>                               Type=simple
> 
>                              
> 
>                               [Install]
> 
>                               WantedBy=multi-user.target
> 
>                              
> 
>                /B.socket/
> 
>                               [Unit]
> 
>                               Description=B.socket
> 
>                               *After=A.service*
> 
> *BindsTo=A.service*
> 
>                              
> 
>                               [Socket]
> 
>                               ListenDatagram=XXXX
> 
>                               Accept=No
> 
>                              
> 
>                               [Install]
> 
>                               WantedBy=sockets.target
> 
>  
> 
>               
> 
>                /B.service/
> 
>                               [Unit]
> 
>                               Description=B.service
> 
>                               Requires=B.socket
> 
>                              
> 
>                               [Service]
> 
>                               Type=simple
> 
>                               ExecStart=/root/test1
> 
>                               StandardInput=socket
> 
>                              
> 
>                               [Install]
> 
>                               WantedBy=multi-user.target
> 
>  
> 
>  
> 
> I need /B.socket/ to start only after /A.service/ during boot. However,
> even after setting */After=A.service/*//and */BindsTo=A.service/*//in
> /B.socket/, sometimes /B.socket/ is starting before /A.service/.
> 
>  
> 
> Please let me know if I am missing something.
> 
>  
> 
>  
> 
> Thanks and Regards,
> 
> Yashashvi
> 
>  
> 
> 
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
> 


-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/


More information about the systemd-devel mailing list