Pacho Ramos <pacho@gentoo.org> lately pointed at how to write systemd unit files for gentoo ebuilds: (1) The servicefile in the current chrony-ebuild still uses forking and has other issues ... I also took (2) as a template ... so I suggest the following 2 service-files. # cat chronyd.service [Unit] Description=Chrony Network Time Service After=ntpdate.service network.target Conflicts=ntpd.service [Service] ExecStart=/usr/sbin/chronyd -r -s -d ControlGroup=cpu:/ [Install] WantedBy=multi-user.target # cat chrony-wait.service [Unit] Description=Wait for chrony to synchronize system clock After=chronyd.service Requires=chronyd.service Before=time-sync.target Wants=time-sync.target [Service] Type=oneshot # Wait up to ~10 minutes for chronyd to synchronize and the remaining # clock correction to be less than 0.1 seconds ExecStart=/usr/bin/chronyc waitsync 60 0.1 RemainAfterExit=yes [Install] WantedBy=multi-user.target Reproducible: Always (1) http://my.opera.com/pacho/blog/2013/08/27/how-to-write-proper-systemd-unit-files (2) http://permalink.gmane.org/gmane.comp.sysutils.systemd.devel/5749
I am all for the no longer forking part, but really unsure about that "wait" service file :/. Is it really needed? How is that being handled by init.d script? Isn't checking for active internet connection enough?
I just copied it from the mentioned link (2) ... AFAI understand it might be needed when another unit after it absolutely needs the synced time ... so we could depend on it. I think the chronyd.service would be enough for now. Please also check if "-d" is OK and not "-n" ... -> http://chrony.tuxfamily.org/manual.html#Starting-chronyd The difference is the logging. Greets.
Will fix existing unit then
+*chrony-1.29-r1 (21 Sep 2013) + + 21 Sep 2013; Pacho Ramos <pacho@gentoo.org> +chrony-1.29-r1.ebuild, + +files/chronyd.service-r1: + Improve unit file (#483456 by Stefan G. Weichinger) +
I'm re-openening this because the current unit has a few problems: 1. Setting Type=simple means that systemd will not detect problems in early startup (like a bad config file), and will continue starting dependent units. Type=forking is actually better here. 2. Passing -r -s by default makes no sense; the default chrony.conf is not set up to support those flags. 3. ControlGroup is no longer supported. 4. Units providing NTP should Conflict with system-timesyncd.service. If there are no objections, I would like to commit the unit below as a replacement. [Unit] Description=Chrony Network Time Service After=ntpdate.service sntp.service network.target Conflicts=ntpd.service systemd-timesyncd.service [Service] Type=forking ExecStart=/usr/sbin/chronyd PIDFile=/run/chronyd.pid [Install] WantedBy=multi-user.target
(In reply to Mike Gilbert from comment #5) > If there are no objections, I would like to commit the unit below as a > replacement. No objections here. Someone who likes/uses chrony+systemd might want to review this, though.
(In reply to Jeroen Roovers from comment #6) > No objections here. Someone who likes/uses chrony+systemd might want to > review this, though. I like systemd and have just started using chrony. ^_^ I'll wait a few days for feedback though.
* I was using "simple" because http://wiki.gentoo.org/wiki/Project:Systemd/Ebuild_policy said so. * ControlGroup: yes, the related warning annoyed me for a long time ;-) * -r -s : ok .. I think the options wouldn't hurt, but OK, it's cleaner this way. If people adjust their config to use that, they can also set up and adjust a specific unit-file in /etc/systemd/system Using your unit-file now for a test ... thanks
(In reply to Stefan G. Weichinger from comment #8) > * I was using "simple" because > > http://wiki.gentoo.org/wiki/Project:Systemd/Ebuild_policy > > said so. > It also says this: "However, Type=forking might be used if it allows distinction between start failures and run-time failures, e.g. configuration file is checked before forking." I checked, and this is indeed the case: chronyd will fail before forking on a config file error.
(In reply to Stefan G. Weichinger from comment #8) > * -r -s : ok .. I think the options wouldn't hurt, but OK, it's cleaner this > way. My main objection is to the -s flag, which resets the system clock to the hardware clock, and assumes the hardware clock is in *local* time by default. That's a horrible assumption to make, and it is not really the job of the NTP daemon in any case. The -r flag causes warnings to appear by default: Sep 04 01:33:27 naomi chronyd[11266]: 2014-09-04T05:33:27Z Could not open dump file ./50.7.68.4.dat Sep 04 01:33:27 naomi chronyd[11266]: 2014-09-04T05:33:27Z Could not open dump file ./198.55.111.50.dat Sep 04 01:33:27 naomi chronyd[11266]: 2014-09-04T05:33:27Z Could not open dump file ./138.236.128.36.dat
I agree with your changes, thank you.
+ 12 Sep 2014; Mike Gilbert <floppym@gentoo.org> +files/chronyd.service-r2, + chrony-1.31.ebuild: + systemd unit improvements, bug 483456. Not sure it is worth a revbump.
(In reply to Mike Gilbert from comment #12) > + 12 Sep 2014; Mike Gilbert <floppym@gentoo.org> +files/chronyd.service-r2, > + chrony-1.31.ebuild: > + systemd unit improvements, bug 483456. > > Not sure it is worth a revbump. 1.31 was added not a day before that.
could we also decide something about https://bugs.gentoo.org/show_bug.cgi?id=499492 while you are at chrony-topics?