Re: [systemd-devel] How can I simply check that a service has been restarted ?

2020-12-19 Thread Lennart Poettering
On Mi, 18.11.20 09:15, Francis Moreau (francis.m...@gmail.com) wrote:

> >
> > Eg:
> >
> > $ busctl get-property org.freedesktop.systemd1 
> > /org/freedesktop/systemd1/unit/gdm_2eservice 
> > org.freedesktop.systemd1.Service NRestarts
> > u 0
> >
>
> I didn't know NRestart property, thanks. But it only counts automatic
> restart, not manual one.
>
> And also there's no need to use busctl, for getting service properties
> I can use 'systemctl show -p'

I am not sure what you even mean by "has been restarted"? Compared to
when?

You could enquire the invocation ID of the service at two points in
time, and if it changed in between the service got restarted.

  $ busctl get-property org.freedesktop.systemd1 
/org/freedesktop/systemd1/unit/gdm_2eservice org.freedesktop.systemd1.Unit 
InvocationID

The invocation is randomly generated whenever a new start cycle begins.

Lennart

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


Re: [systemd-devel] How can I simply check that a service has been restarted ?

2020-12-19 Thread Lennart Poettering
On Di, 10.11.20 12:47, Arian Van Putten (ar...@wire.com) wrote:

> I think what you might want is `Type=exec` instead of `Type=simple` in your
> unit file.  It was recently added to systemd.

Recently? That was in 2018! 2 Years ago!

Lennart

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


Re: [systemd-devel] How can I simply check that a service has been restarted ?

2020-11-18 Thread Francis Moreau
On Tue, Nov 10, 2020 at 6:35 PM Luca Boccassi  wrote:
>
> On Tue, 2020-11-10 at 17:22 +, Luca Boccassi wrote:
> > On Tue, 2020-11-10 at 18:12 +0100, Francis Moreau wrote:
> > > On Tue, Nov 10, 2020 at 2:43 PM Luca Boccassi  wrote:
> > > > On Tue, 2020-11-10 at 11:50 +0100, Francis Moreau wrote:
> > > > > On Tue, Nov 10, 2020 at 11:30 AM Lennart Poettering
> > > > >  wrote:
> > > > > > On Di, 10.11.20 10:28, Francis Moreau (francis.m...@gmail.com) 
> > > > > > wrote:
> > > > > >
> > > > > > > Hello,
> > > > > > >
> > > > > > > After restarting a service with "systemctl try-restart ..." I 
> > > > > > > want to
> > > > > > > verify that the service has been restarted.
> > > > > > >
> > > > > > > How can I reliably do this without using the dbus API ?
> > > > > >
> > > > > > D-Bus is how systemd exposes its state. If you don't want to use 
> > > > > > that,
> > > > > > you won't get the state information.
> > > > > >
> > > > >
> > > > > dbus is overkill for my little bash script.
> > > >
> > > > It's pretty simple, and a one-liner, to get the value of a property
> > > > from a bash script with busctl. Eg:
> > > >
> > > > $ busctl get-property org.freedesktop.systemd1 
> > > > /org/freedesktop/systemd1/unit/gdm_2eservice 
> > > > org.freedesktop.systemd1.Service Restart
> > > > s "always"
> > > >
> > >
> > > Thank you but I'm not interested in the Restart property of a service,
> > > I want to know if a service as been restarted.
> >
> > It's just an example on how to get D-Bus data on units easily from a
> > bash script.
>
> Eg:
>
> $ busctl get-property org.freedesktop.systemd1 
> /org/freedesktop/systemd1/unit/gdm_2eservice org.freedesktop.systemd1.Service 
> NRestarts
> u 0
>

I didn't know NRestart property, thanks. But it only counts automatic
restart, not manual one.

And also there's no need to use busctl, for getting service properties
I can use 'systemctl show -p'

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


Re: [systemd-devel] How can I simply check that a service has been restarted ?

2020-11-10 Thread Luca Boccassi
On Tue, 2020-11-10 at 17:22 +, Luca Boccassi wrote:
> On Tue, 2020-11-10 at 18:12 +0100, Francis Moreau wrote:
> > On Tue, Nov 10, 2020 at 2:43 PM Luca Boccassi  wrote:
> > > On Tue, 2020-11-10 at 11:50 +0100, Francis Moreau wrote:
> > > > On Tue, Nov 10, 2020 at 11:30 AM Lennart Poettering
> > > >  wrote:
> > > > > On Di, 10.11.20 10:28, Francis Moreau (francis.m...@gmail.com) wrote:
> > > > > 
> > > > > > Hello,
> > > > > > 
> > > > > > After restarting a service with "systemctl try-restart ..." I want 
> > > > > > to
> > > > > > verify that the service has been restarted.
> > > > > > 
> > > > > > How can I reliably do this without using the dbus API ?
> > > > > 
> > > > > D-Bus is how systemd exposes its state. If you don't want to use that,
> > > > > you won't get the state information.
> > > > > 
> > > > 
> > > > dbus is overkill for my little bash script.
> > > 
> > > It's pretty simple, and a one-liner, to get the value of a property
> > > from a bash script with busctl. Eg:
> > > 
> > > $ busctl get-property org.freedesktop.systemd1 
> > > /org/freedesktop/systemd1/unit/gdm_2eservice 
> > > org.freedesktop.systemd1.Service Restart
> > > s "always"
> > > 
> > 
> > Thank you but I'm not interested in the Restart property of a service,
> > I want to know if a service as been restarted.
> 
> It's just an example on how to get D-Bus data on units easily from a
> bash script.

Eg:

$ busctl get-property org.freedesktop.systemd1 
/org/freedesktop/systemd1/unit/gdm_2eservice org.freedesktop.systemd1.Service 
NRestarts
u 0

-- 
Kind regards,
Luca Boccassi
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How can I simply check that a service has been restarted ?

2020-11-10 Thread Luca Boccassi
On Tue, 2020-11-10 at 18:12 +0100, Francis Moreau wrote:
> On Tue, Nov 10, 2020 at 2:43 PM Luca Boccassi  wrote:
> > On Tue, 2020-11-10 at 11:50 +0100, Francis Moreau wrote:
> > > On Tue, Nov 10, 2020 at 11:30 AM Lennart Poettering
> > >  wrote:
> > > > On Di, 10.11.20 10:28, Francis Moreau (francis.m...@gmail.com) wrote:
> > > > 
> > > > > Hello,
> > > > > 
> > > > > After restarting a service with "systemctl try-restart ..." I want to
> > > > > verify that the service has been restarted.
> > > > > 
> > > > > How can I reliably do this without using the dbus API ?
> > > > 
> > > > D-Bus is how systemd exposes its state. If you don't want to use that,
> > > > you won't get the state information.
> > > > 
> > > 
> > > dbus is overkill for my little bash script.
> > 
> > It's pretty simple, and a one-liner, to get the value of a property
> > from a bash script with busctl. Eg:
> > 
> > $ busctl get-property org.freedesktop.systemd1 
> > /org/freedesktop/systemd1/unit/gdm_2eservice 
> > org.freedesktop.systemd1.Service Restart
> > s "always"
> > 
> 
> Thank you but I'm not interested in the Restart property of a service,
> I want to know if a service as been restarted.

It's just an example on how to get D-Bus data on units easily from a
bash script.

-- 
Kind regards,
Luca Boccassi
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How can I simply check that a service has been restarted ?

2020-11-10 Thread Francis Moreau
On Tue, Nov 10, 2020 at 2:43 PM Luca Boccassi  wrote:
>
> On Tue, 2020-11-10 at 11:50 +0100, Francis Moreau wrote:
> > On Tue, Nov 10, 2020 at 11:30 AM Lennart Poettering
> >  wrote:
> > > On Di, 10.11.20 10:28, Francis Moreau (francis.m...@gmail.com) wrote:
> > >
> > > > Hello,
> > > >
> > > > After restarting a service with "systemctl try-restart ..." I want to
> > > > verify that the service has been restarted.
> > > >
> > > > How can I reliably do this without using the dbus API ?
> > >
> > > D-Bus is how systemd exposes its state. If you don't want to use that,
> > > you won't get the state information.
> > >
> >
> > dbus is overkill for my little bash script.
>
> It's pretty simple, and a one-liner, to get the value of a property
> from a bash script with busctl. Eg:
>
> $ busctl get-property org.freedesktop.systemd1 
> /org/freedesktop/systemd1/unit/gdm_2eservice org.freedesktop.systemd1.Service 
> Restart
> s "always"
>

Thank you but I'm not interested in the Restart property of a service,
I want to know if a service as been restarted.

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


Re: [systemd-devel] How can I simply check that a service has been restarted ?

2020-11-10 Thread Luca Boccassi
On Tue, 2020-11-10 at 11:50 +0100, Francis Moreau wrote:
> On Tue, Nov 10, 2020 at 11:30 AM Lennart Poettering
>  wrote:
> > On Di, 10.11.20 10:28, Francis Moreau (francis.m...@gmail.com) wrote:
> > 
> > > Hello,
> > > 
> > > After restarting a service with "systemctl try-restart ..." I want to
> > > verify that the service has been restarted.
> > > 
> > > How can I reliably do this without using the dbus API ?
> > 
> > D-Bus is how systemd exposes its state. If you don't want to use that,
> > you won't get the state information.
> > 
> 
> dbus is overkill for my little bash script.

It's pretty simple, and a one-liner, to get the value of a property
from a bash script with busctl. Eg:

$ busctl get-property org.freedesktop.systemd1 
/org/freedesktop/systemd1/unit/gdm_2eservice org.freedesktop.systemd1.Service 
Restart
s "always"

-- 
Kind regards,
Luca Boccassi
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How can I simply check that a service has been restarted ?

2020-11-10 Thread Francis Moreau
On Tue, Nov 10, 2020 at 12:47 PM Arian Van Putten  wrote:
>
> I think what you might want is `Type=exec` instead of `Type=simple` in your 
> unit file.  It was recently added to systemd.
>
> then `systemctl restart` will return a failure when the main process fails to 
> start. I hope that helps.

Thank you however I don't control the type of the restarted units, it
can be anything,

>
>
> On Tue, Nov 10, 2020 at 11:50 AM Francis Moreau  
> wrote:
>>
>> On Tue, Nov 10, 2020 at 11:30 AM Lennart Poettering
>>  wrote:
>> >
>> > On Di, 10.11.20 10:28, Francis Moreau (francis.m...@gmail.com) wrote:
>> >
>> > > Hello,
>> > >
>> > > After restarting a service with "systemctl try-restart ..." I want to
>> > > verify that the service has been restarted.
>> > >
>> > > How can I reliably do this without using the dbus API ?
>> >
>> > D-Bus is how systemd exposes its state. If you don't want to use that,
>> > you won't get the state information.
>> >
>>
>> dbus is overkill for my little bash script.
>>
>> --
>> Francis
>> ___
>> systemd-devel mailing list
>> systemd-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
>
>
> --
>
> Arian van Putten  l  Software Engineer
>
> @arian_wire on Wire
>
> Wire - Secure team messaging.
>
>  Zeta Project Germany GmbH  l  Rosenthaler Straße 40, 10178 Berlin, Germany
>
> Geschäftsführer/Managing Director: Morten J. Broegger
>
> HRB 149847 beim Handelsregister Charlottenburg, Berlin
>
> VAT-ID DE288748675



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


Re: [systemd-devel] How can I simply check that a service has been restarted ?

2020-11-10 Thread Arian Van Putten
I think what you might want is `Type=exec` instead of `Type=simple` in your
unit file.  It was recently added to systemd.

then `systemctl restart` will return a failure when the main process fails
to start. I hope that helps.



On Tue, Nov 10, 2020 at 11:50 AM Francis Moreau 
wrote:

> On Tue, Nov 10, 2020 at 11:30 AM Lennart Poettering
>  wrote:
> >
> > On Di, 10.11.20 10:28, Francis Moreau (francis.m...@gmail.com) wrote:
> >
> > > Hello,
> > >
> > > After restarting a service with "systemctl try-restart ..." I want to
> > > verify that the service has been restarted.
> > >
> > > How can I reliably do this without using the dbus API ?
> >
> > D-Bus is how systemd exposes its state. If you don't want to use that,
> > you won't get the state information.
> >
>
> dbus is overkill for my little bash script.
>
> --
> Francis
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>


-- 

Arian van Putten  l  Software Engineer

@arian_wire on Wire

Wire  - Secure team messaging.

 Zeta Project Germany GmbH  l  Rosenthaler Straße 40, 10178 Berlin, Germany



Geschäftsführer/Managing Director: Morten J. Broegger

HRB 149847 beim Handelsregister Charlottenburg, Berlin

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


Re: [systemd-devel] How can I simply check that a service has been restarted ?

2020-11-10 Thread Francis Moreau
On Tue, Nov 10, 2020 at 11:30 AM Lennart Poettering
 wrote:
>
> On Di, 10.11.20 10:28, Francis Moreau (francis.m...@gmail.com) wrote:
>
> > Hello,
> >
> > After restarting a service with "systemctl try-restart ..." I want to
> > verify that the service has been restarted.
> >
> > How can I reliably do this without using the dbus API ?
>
> D-Bus is how systemd exposes its state. If you don't want to use that,
> you won't get the state information.
>

dbus is overkill for my little bash script.

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


Re: [systemd-devel] How can I simply check that a service has been restarted ?

2020-11-10 Thread Lennart Poettering
On Di, 10.11.20 10:28, Francis Moreau (francis.m...@gmail.com) wrote:

> Hello,
>
> After restarting a service with "systemctl try-restart ..." I want to
> verify that the service has been restarted.
>
> How can I reliably do this without using the dbus API ?

D-Bus is how systemd exposes its state. If you don't want to use that,
you won't get the state information.

Sorry,

Lennart

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


[systemd-devel] How can I simply check that a service has been restarted ?

2020-11-10 Thread Francis Moreau
Hello,

After restarting a service with "systemctl try-restart ..." I want to
verify that the service has been restarted.

How can I reliably do this without using the dbus API ?

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