Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Feb 2017 09:29:47 -0700
From:      Alan Somers <asomers@freebsd.org>
To:        "Martin S. Weber" <Ephaeton@gmx.net>
Cc:        Cy Schubert <Cy.Schubert@komquats.com>, scrappy@freebsd.org,  Brian Somers <brian@freebsd.org>, freebsd-bugzilla@ayaken.net,  Cy Schubert <cy@freebsd.org>, pkg@freebsd.org, =?UTF-8?Q?Dag=2DErling_Sm=C3=B8rgrav?= <des@freebsd.org>
Subject:   Re: Bug 217055 - Consolidate random sleeps in periodic scripts
Message-ID:  <CAOtMX2ic=y_ZHCKRg3OF_aGWdKXbPv0UkVze3APW=7LWO9W1xg@mail.gmail.com>
In-Reply-To: <20170214113643.GA3593@hephaistos.local>
References:  <asomers@freebsd.org> <CAOtMX2jr6=-fmzni537JbzRv6f9YvsrHHPgnt5HnNLjLgjd5OQ@mail.gmail.com> <201702140647.v1E6lVd8078946@slippy.cwsent.com> <20170214113643.GA3593@hephaistos.local>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Feb 14, 2017 at 4:36 AM, Martin S. Weber <Ephaeton@gmx.net> wrote:
> On 2017-02-13 22:47:31, Cy Schubert wrote:
> (...)
>> Hi Alan,
>>
>> Looking at ntp, it backgrounds itself:
>>
>>       (sleep $(jot -r 1 0 3600); service ntpd onefetch) &
>>
>> To facilitate debugging, I can commit the following, if you don't mind.
>>
>> Index: periodic/daily/480.leapfile-ntpd
>> ===================================================================
>> --- periodic/daily/480.leapfile-ntpd  (revision 313710)
>> +++ periodic/daily/480.leapfile-ntpd  (working copy)
>> @@ -13,6 +13,7 @@
>>
>>  case "$daily_ntpd_leapfile_enable" in
>>      [Yy][Ee][Ss])
>> +     tty >/dev/null 2>&1 && daily_ntpd_avoid_congestion=NO
>>       case "$daily_ntpd_avoid_congestion" in
>>       [Yy][Ee][Ss])
>>           # Avoid dogpiling
>
> You are aware that these files are invoked with < /dev/null and > file 2>&1 ?
>
> Problem with sleeping from periodic from the command line is that these
> extra I/O indirections make it impossible from the script file itself
> to determine whether or not the parent process is running from a tty
> or not.
>
> Cf. /usr/sbin/periodic:118
>
> For the purpose of "my" PR, your fix is useless. An environment variable
> could be set that stored the fact whether or not invoker is on a TTY,
> and this again be checked from within the periodic scripts themselves
> to determine whether or not we should sleep.
>
> Btw, I hate systemd & dbus, but the discussion so far really looks like
> the vanilla argument "pro" SOA-style module startup :(
>
> Regards,
>
> -Martin

Ok, the consensus opinion seems to be that:
1) A single sleep would be better than 3 sleeps
2) Periodic shouldn't sleep if no script requires it
3) Nothing should be backgrounded
4) Periodic shouldn't sleep when run interactively.

I can achieve all of this by putting a common sleep function in
/etc/defaults/periodic.conf.  Some passing of environment variables
will be required.  I'll put everyone on the code review when it's
ready.

-Alan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAOtMX2ic=y_ZHCKRg3OF_aGWdKXbPv0UkVze3APW=7LWO9W1xg>