Re: [systemd-devel] Question on Before=

2019-02-02 Thread Steve Dickson


On 2/2/19 3:44 PM, Reindl Harald wrote:
> 
> 
> Am 02.02.19 um 21:05 schrieb Steve Dickson:
>> On 2/2/19 2:52 PM, Reindl Harald wrote:
>>> Am 02.02.19 um 20:42 schrieb Steve Dickson:
 Hello,

 In a.service  I have 

 [Unit]
 Before=b.service 

 [Install]
 RequiredBy=b.service

 when I systemd start b.service (which happens to fail) 
 but... a.service is not being run.

 So I guess my question is what do I have to do
 to ensure a.service is *always* run before b.service?
>>>
 [Install]
 RequiredBy=b.service
>>>
>>> why?
>>>
>>> [Unit]
>>> Before/After/Require
>>>
>>> [Install]
>>> WantedBy=multi-user.target
>> Because a.service only needs to run when b.service is started. 
> 
> this is a cirrcualr dependency!
> 
> you say "start a before b" and at the same time "start a only when b is
> started"
> 
> hwo do you imagine that to work?
> 
That a would start before b because of the Before= in a.

There was an issue as how I was enabling a... 

thanks for the help!

steved.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Question on Before=

2019-02-02 Thread Steve Dickson


On 2/2/19 4:03 PM, Tomasz Torcz wrote:
> On Sat, Feb 02, 2019 at 03:03:22PM -0500, Steve Dickson wrote:
>>
>>
>> On 2/2/19 2:48 PM, Tomasz Torcz wrote:
>>> On Sat, Feb 02, 2019 at 02:42:15PM -0500, Steve Dickson wrote:
 Hello,

 In a.service  I have 

 [Unit]
 Before=b.service 

 [Install]
 RequiredBy=b.service

 when I systemd start b.service (which happens to fail) 
 but... a.service is not being run.

 So I guess my question is what do I have to do
 to ensure a.service is *always* run before b.service?
>>>
>>>   Have you enabled a.service?
>>>
>> No... I did not think I had to... I figured 
>> when b.service was started, a.service would be 
>> run regardless of being enabled or disabled.
>>
>> Is that not the case?
> 
>   Not really.  It would work, if you had in b.service line like
> Requires=a.service (*).
>   But apparently you do not want to modify b.service, so you
> put RequiredBy= in a.service's [Install] section. Directives
> in [Install] section requires "systemctl enable" to have symlinks
> created and to have effect. After enable, it will work identical to (*).
> 
>   Nb. most services have RequireBy=multi-user.target (or WantedBy=). For
> such services, enabling mean they will start at boot (beacuse
> multi-user.target is part of boot process).  But there is not
> requirement for services to be Wanted/Required by not boot-related
> services and target.
>   Thus, you often find in tutorials assertion that 
> "systemctl enable" equals "start during boot". This is not true.
It turns out I had a bug in my spec file logic which should
have enabled the service... 

Thanks for the help!

steved.

> 
> 
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Question on Before=

2019-02-02 Thread Steve Dickson


On 2/2/19 4:07 PM, Uoti Urpala wrote:
> On Sat, 2019-02-02 at 15:03 -0500, Steve Dickson wrote:
>>>   Have you enabled a.service?
>>>
>> No... I did not think I had to... I figured 
>> when b.service was started, a.service would be 
>> run regardless of being enabled or disabled.
>>
>> Is that not the case?
> 
> So you just have the file for a.service lying somewhere on disk, but
> haven't enabled it and no other unit references it? 
That is true... 

> That won't do anything - systemd does not read through all files on disk to 
> see if
> there'd be something inside the file which declares that it should
> actually be started. Units need to have something else referencing them
> for systemd to "see" them at all. "enable" does this by creating a link
> from the units/targets referenced in the [Install] section to the file
> in question (by creating a symlink in 
> /etc/systemd/system/multi-user.target.wants/ for example).
Basically enabling the service... fair enough... 

steved.

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Question on Before=

2019-02-02 Thread Tomasz Torcz
On Sat, Feb 02, 2019 at 03:03:22PM -0500, Steve Dickson wrote:
> 
> 
> On 2/2/19 2:48 PM, Tomasz Torcz wrote:
> > On Sat, Feb 02, 2019 at 02:42:15PM -0500, Steve Dickson wrote:
> >> Hello,
> >>
> >> In a.service  I have 
> >>
> >> [Unit]
> >> Before=b.service 
> >>
> >> [Install]
> >> RequiredBy=b.service
> >>
> >> when I systemd start b.service (which happens to fail) 
> >> but... a.service is not being run.
> >>
> >> So I guess my question is what do I have to do
> >> to ensure a.service is *always* run before b.service?
> > 
> >   Have you enabled a.service?
> > 
> No... I did not think I had to... I figured 
> when b.service was started, a.service would be 
> run regardless of being enabled or disabled.
> 
> Is that not the case?

  Not really.  It would work, if you had in b.service line like
Requires=a.service (*).
  But apparently you do not want to modify b.service, so you
put RequiredBy= in a.service's [Install] section. Directives
in [Install] section requires "systemctl enable" to have symlinks
created and to have effect. After enable, it will work identical to (*).

  Nb. most services have RequireBy=multi-user.target (or WantedBy=). For
such services, enabling mean they will start at boot (beacuse
multi-user.target is part of boot process).  But there is not
requirement for services to be Wanted/Required by not boot-related
services and target.
  Thus, you often find in tutorials assertion that 
"systemctl enable" equals "start during boot". This is not true.


-- 
Tomasz Torcz"Funeral in the morning, IDE hacking
xmpp: zdzich...@chrome.plin the afternoon and evening." - Alan Cox

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Question on Before=

2019-02-02 Thread Uoti Urpala
On Sat, 2019-02-02 at 15:03 -0500, Steve Dickson wrote:
> >   Have you enabled a.service?
> > 
> No... I did not think I had to... I figured 
> when b.service was started, a.service would be 
> run regardless of being enabled or disabled.
> 
> Is that not the case?

So you just have the file for a.service lying somewhere on disk, but
haven't enabled it and no other unit references it? That won't do
anything - systemd does not read through all files on disk to see if
there'd be something inside the file which declares that it should
actually be started. Units need to have something else referencing them
for systemd to "see" them at all. "enable" does this by creating a link
from the units/targets referenced in the [Install] section to the file
in question (by creating a symlink in 
/etc/systemd/system/multi-user.target.wants/ for example).


___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Question on Before=

2019-02-02 Thread Reindl Harald


Am 02.02.19 um 21:05 schrieb Steve Dickson:
> On 2/2/19 2:52 PM, Reindl Harald wrote:
>> Am 02.02.19 um 20:42 schrieb Steve Dickson:
>>> Hello,
>>>
>>> In a.service  I have 
>>>
>>> [Unit]
>>> Before=b.service 
>>>
>>> [Install]
>>> RequiredBy=b.service
>>>
>>> when I systemd start b.service (which happens to fail) 
>>> but... a.service is not being run.
>>>
>>> So I guess my question is what do I have to do
>>> to ensure a.service is *always* run before b.service?
>>
>>> [Install]
>>> RequiredBy=b.service
>>
>> why?
>>
>> [Unit]
>> Before/After/Require
>>
>> [Install]
>> WantedBy=multi-user.target
> Because a.service only needs to run when b.service is started. 

this is a cirrcualr dependency!

you say "start a before b" and at the same time "start a only when b is
started"

hwo do you imagine that to work?

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Question on Before=

2019-02-02 Thread Reindl Harald


Am 02.02.19 um 21:03 schrieb Steve Dickson:
> On 2/2/19 2:48 PM, Tomasz Torcz wrote:
>> On Sat, Feb 02, 2019 at 02:42:15PM -0500, Steve Dickson wrote:
>>> Hello,
>>>
>>> In a.service  I have 
>>>
>>> [Unit]
>>> Before=b.service 
>>>
>>> [Install]
>>> RequiredBy=b.service
>>>
>>> when I systemd start b.service (which happens to fail) 
>>> but... a.service is not being run.
>>>
>>> So I guess my question is what do I have to do
>>> to ensure a.service is *always* run before b.service?
>>
>>   Have you enabled a.service?
>>
> No... I did not think I had to... I figured 
> when b.service was started, a.service would be 
> run regardless of being enabled or disabled.
> 
> Is that not the case?

that's not how it works


___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Question on Before=

2019-02-02 Thread Steve Dickson


On 2/2/19 2:52 PM, Reindl Harald wrote:
> 
> 
> Am 02.02.19 um 20:42 schrieb Steve Dickson:
>> Hello,
>>
>> In a.service  I have 
>>
>> [Unit]
>> Before=b.service 
>>
>> [Install]
>> RequiredBy=b.service
>>
>> when I systemd start b.service (which happens to fail) 
>> but... a.service is not being run.
>>
>> So I guess my question is what do I have to do
>> to ensure a.service is *always* run before b.service?
> 
>> [Install]
>> RequiredBy=b.service
> 
> why?
> 
> [Unit]
> Before/After/Require
> 
> [Install]
> WantedBy=multi-user.target
Because a.service only needs to run when b.service is started. 

steved.

> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
> 
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Question on Before=

2019-02-02 Thread Steve Dickson


On 2/2/19 2:48 PM, Tomasz Torcz wrote:
> On Sat, Feb 02, 2019 at 02:42:15PM -0500, Steve Dickson wrote:
>> Hello,
>>
>> In a.service  I have 
>>
>> [Unit]
>> Before=b.service 
>>
>> [Install]
>> RequiredBy=b.service
>>
>> when I systemd start b.service (which happens to fail) 
>> but... a.service is not being run.
>>
>> So I guess my question is what do I have to do
>> to ensure a.service is *always* run before b.service?
> 
>   Have you enabled a.service?
> 
No... I did not think I had to... I figured 
when b.service was started, a.service would be 
run regardless of being enabled or disabled.

Is that not the case?

steved.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Question on Before=

2019-02-02 Thread Tomasz Torcz
On Sat, Feb 02, 2019 at 02:42:15PM -0500, Steve Dickson wrote:
> Hello,
> 
> In a.service  I have 
> 
> [Unit]
> Before=b.service 
> 
> [Install]
> RequiredBy=b.service
> 
> when I systemd start b.service (which happens to fail) 
> but... a.service is not being run.
> 
> So I guess my question is what do I have to do
> to ensure a.service is *always* run before b.service?

  Have you enabled a.service?

-- 
Tomasz Torcz"Funeral in the morning, IDE hacking
xmpp: zdzich...@chrome.plin the afternoon and evening." - Alan Cox

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Question on Before=

2019-02-02 Thread Reindl Harald


Am 02.02.19 um 20:42 schrieb Steve Dickson:
> Hello,
> 
> In a.service  I have 
> 
> [Unit]
> Before=b.service 
> 
> [Install]
> RequiredBy=b.service
> 
> when I systemd start b.service (which happens to fail) 
> but... a.service is not being run.
> 
> So I guess my question is what do I have to do
> to ensure a.service is *always* run before b.service?

> [Install]
> RequiredBy=b.service

why?

[Unit]
Before/After/Require

[Install]
WantedBy=multi-user.target
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Question on Before=

2019-02-02 Thread Steve Dickson
Hello,

In a.service  I have 

[Unit]
Before=b.service 

[Install]
RequiredBy=b.service

when I systemd start b.service (which happens to fail) 
but... a.service is not being run.

So I guess my question is what do I have to do
to ensure a.service is *always* run before b.service?

tia,

steved. 
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How to schedule a resource consuming service

2019-02-02 Thread Andrei Borzenkov
02.02.2019 16:50, Fabrice Salvaire пишет:
> Dear all,
> 
> In Fedora mlocate (updatedb) service is setup like this
> 
> --
> 
>> cat /usr/lib/systemd/system/mlocate-updatedb.service
> [Unit]
> Description=Update a database for mlocate
> 
> [Service]
> ExecStart=/usr/libexec/mlocate-run-updatedb
> Nice=19
> IOSchedulingClass=2
> IOSchedulingPriority=7
> 
> PrivateTmp=true
> PrivateDevices=true
> PrivateNetwork=true
> ProtectSystem=true
> 
> --
> 
>> cat /usr/lib/systemd/system/mlocate-updatedb.timer
> [Unit]
> Description=Updates mlocate database every day
> 
> [Timer]
> OnCalendar=daily
> AccuracySec=24h
> Persistent=true
> 
> [Install]
> WantedBy=timers.target
> --
> 
> Unfortunately it saturates the IO after the boot when the machine was
> not running at midnight (not sure ???), see
> https://bugzilla.redhat.com/show_bug.cgi?id=1282232
> 

Similar problem was discussed for openSUSE as well (similar in the sense
that Persistent=true results in serious impact during boot). Some way to
delay Persistent=true would be nice indeed.

> This is painful when we want to use the machine asap, for a quite full
> 500 GB disk, it hangs during several minutes.  I encountered an unusable
> machine during more than 10 min due to mlocate and/or gnome indexer
> saturating IO and package cache update saturating a low ADSL connexion.
> 
> I noticed IOSchedulingClass=2 could be set to "idle", maybe it would
> improve.
> 
> I also read
> https://www.freedesktop.org/software/systemd/man/systemd.timer.html but
> I don't understand if there is a way to prevent to run the service
> during 1h after boot.
> 
> Well a way to run theses services during idle time.
> 

Define "idle time" ...
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] How to schedule a resource consuming service

2019-02-02 Thread Fabrice Salvaire

Dear all,

In Fedora mlocate (updatedb) service is setup like this

--

> cat /usr/lib/systemd/system/mlocate-updatedb.service
[Unit]
Description=Update a database for mlocate

[Service]
ExecStart=/usr/libexec/mlocate-run-updatedb
Nice=19
IOSchedulingClass=2
IOSchedulingPriority=7

PrivateTmp=true
PrivateDevices=true
PrivateNetwork=true
ProtectSystem=true

--

> cat /usr/lib/systemd/system/mlocate-updatedb.timer
[Unit]
Description=Updates mlocate database every day

[Timer]
OnCalendar=daily
AccuracySec=24h
Persistent=true

[Install]
WantedBy=timers.target
--

Unfortunately it saturates the IO after the boot when the machine was 
not running at midnight (not sure ???), see 
https://bugzilla.redhat.com/show_bug.cgi?id=1282232


This is painful when we want to use the machine asap, for a quite full 
500 GB disk, it hangs during several minutes.  I encountered an unusable 
machine during more than 10 min due to mlocate and/or gnome indexer 
saturating IO and package cache update saturating a low ADSL connexion.


I noticed IOSchedulingClass=2 could be set to "idle", maybe it would 
improve.


I also read 
https://www.freedesktop.org/software/systemd/man/systemd.timer.html but 
I don't understand if there is a way to prevent to run the service 
during 1h after boot.


Well a way to run theses services during idle time.

Cheers,

Fabrice



___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel