Re: [systemd-devel] systemctl is-active command returns inactive even if the unit does not exist

2018-01-24 Thread Michael Chapman

On Thu, 25 Jan 2018, Kevin Hsu wrote:

Hi folks,

"systemctl is-active" command gives "inactive" no matter the unit exists
and indeed inactive or it just not exist. This behavior is semantically
true since a unit can never be active
if it does not exist. But "systemctl is-enabled" command will give a clear
result "Failed to get unit file state for no-exist.service: No such file or
directory" to indicate user the existence
of the given unit. I am wondering if "systemctl is-active" should behave
the same.


I don't think it would be possible to change what "systemctl is-active" 
prints out now, and I think it makes sense for it to track the ActiveState 
property of the unit precisely.


You can get the properties of a unit using "systemctl show". For example:

  $ systemctl show --property LoadState,ActiveState,SubState \
does-not-exist.service
  LoadState=not-found
  ActiveState=inactive
  SubState=dead

As you can see here, what you're interested in is the "load state" of the 
unit, which is somewhat orthogonal to the unit's "active state".

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


[systemd-devel] systemctl is-active command returns inactive even if the unit does not exist

2018-01-24 Thread Kevin Hsu
Hi folks,

"systemctl is-active" command gives "inactive" no matter the unit exists
and indeed inactive or it just not exist. This behavior is semantically
true since a unit can never be active
if it does not exist. But "systemctl is-enabled" command will give a clear
result "Failed to get unit file state for no-exist.service: No such file or
directory" to indicate user the existence
of the given unit. I am wondering if "systemctl is-active" should behave
the same.


systemctl --version

systemd 235


systemctl is-active non-exist.service

inactive

systemctl is-enabled non-exist.service
Failed to get unit file state for non-exist.service: No such file or
directory

Best regards,
Kevin Hsu
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] systemctl is-active

2018-01-15 Thread vcaputo
On Tue, Jan 16, 2018 at 12:17:52AM +0100, Michał Zegan wrote:
> Hello.
> When systemctl is-active was added?
> I need this to check if I can safely use it to check if unit is active
> if I don't have prior knowledge about the systemd version I am running
> this on, this is for an ansible playbook.
> 

It appears "is-active" was added to systemctl as part of:

 commit ee5762e3780c048b230e8c1e7659e40fc1f443bf
 Author: Lennart Poettering 
 Date:   Sat Jul 24 00:53:33 2010 +0200
 
 systemctl: fold systemd-install into systemctl
 

The earliest tagged release this commit made it into according to
`git tag --contains ee5762e378` is v4.

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


[systemd-devel] systemctl is-active

2018-01-15 Thread Michał Zegan
Hello.
When systemctl is-active was added?
I need this to check if I can safely use it to check if unit is active
if I don't have prior knowledge about the systemd version I am running
this on, this is for an ansible playbook.



signature.asc
Description: OpenPGP digital signature
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel