Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix systemctl is active #773

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion testinfra/modules/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,12 @@ def exists(self):

@property
def is_running(self):
out = self.run_expect([0, 1, 3], "systemctl is-active %s", self.name)
# based on https://man7.org/linux/man-pages/man1/systemctl.1.html
# 0: program running
# 1: program is dead and pid file exists
# 3: not running and pid file does not exists
# 4: Unable to determine status (no such unit)
out = self.run_expect([0, 1, 3, 4], "systemctl is-active %s", self.name)
if out.rc == 1:
# Failed to connect to bus: No such file or directory
return super().is_running
Expand Down