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):
169
169
170
170
def _has_systemd_suffix (self ):
171
171
"""
172
- Check if service name has a known systemd unit suffix
172
+ Check if the service name has a known systemd unit suffix
173
173
"""
174
174
unit_suffix = self .name .split ("." )[- 1 ]
175
175
return unit_suffix in self .suffix_list
176
176
177
177
@property
178
178
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
181
187
182
188
@property
183
189
def is_running (self ):
You can’t perform that action at this time.
0 commit comments