[systemd-devel] Only start a tomcat server when you are sure that time-sync.target is online

Reindl Harald h.reindl at thelounge.net
Thu Mar 25 14:37:49 UTC 2021



Am 25.03.21 um 15:11 schrieb Jan Hugo Prins:
>> > Does systemd give me a different way to check if the time is in sync?
>> > Is there a way to create this dependency without implying a restart when
>> > ntpd restarts?
>> https://unix.stackexchange.com/questions/388586/systemd-requires-vs-wants 
>> <https://unix.stackexchange.com/questions/388586/systemd-requires-vs-wants>
>>
>> just replace "Requires" with "Wants", it does exactly the same but your
>> Tomcat would also get started if "time-sync.target" is missing *but* it
>> would not be stopped just because ntpd is stopped
>>
>> there are really very few cases when Requires is really what someone wants
> 
> We first tried it with wants, but wants does start the application 
> server even if the time-sync.target does not work.
> 
>  From the man page:
>             Units listed in this option will be started if the 
> configuring unit is. *However, if the listed units fail to start or 
> cannot be added to the**
> **           transaction, this has no impact on the validity of the 
> transaction as a whole*, and this unit will still be started. This is 
> the recommended
>             way to hook the start-up of one unit to the start-up of 
> another unit.
> 
> We don't want tomcat to start when time-sync doesn't succeed, but when 
> ntpd restarts it should not influence tomcat.

you need to chose one death

when you say "it requires X" the logical result of taking X down is that 
both are going down

how high is the chance that ntpd don't start and in the reality (didn't 
have that a single time) how large is the drift on a typical 365/24 on 
machine at reboot?

in fact look at "ntpq -p" after restart - it take ssome time until it 
really is operational no matter if it started successful

you are creating more troubles than you solve and should better make 
sure that ntpd.service is automatically restarted in case it fails and 
is properly ordered after network


More information about the systemd-devel mailing list