File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -169,15 +169,21 @@ class SystemdService(SysvService):
169169
170170 def _has_systemd_suffix (self ):
171171 """
172- Check if service name has a known systemd unit suffix
172+ Check if the service name has a known systemd unit suffix
173173 """
174174 unit_suffix = self .name .split ("." )[- 1 ]
175175 return unit_suffix in self .suffix_list
176176
177177 @property
178178 def exists (self ):
179- cmd = self .run_test ('systemctl list-unit-files | grep -q "^%s"' , self .name )
180- return cmd .rc == 0
179+ # systemctl return codes:
180+ # 0: unit is active
181+ # 1: unit not failed (used by is-failed)
182+ # 2: unused
183+ # 3: unit is not active
184+ # 4: no such unit
185+ cmd = self .run_test (r"systemctl status %s" , self .name )
186+ return cmd .rc < 4
181187
182188 @property
183189 def is_running (self ):
You can’t perform that action at this time.
0 commit comments