Skip to content

Commit

Permalink
Merge pull request #104 from KwisatzHaderach/systemd_service
Browse files Browse the repository at this point in the history
Add logger info with journalctl output when systemd service action fails
  • Loading branch information
petr-balogh authored May 16, 2018
2 parents 6baa740 + c6bd126 commit 302e398
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions rrmngmnt/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ def _execute(self, action):
]
executor = self.host.executor()
rc, _, _ = executor.run_cmd(cmd, io_timeout=self.timeout)

if rc:
cmd = ['journalctl', '-u', self.name + ".service"]
_, out, _ = executor.run_cmd(cmd, io_timeout=self.timeout)
self.logger.warning(out)

return rc == 0

def is_enabled(self):
Expand Down
4 changes: 4 additions & 0 deletions tests/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,17 @@ class TestSystemd(TestSystemService):
),
'systemctl is-enabled s-enabled.service': (0, '', ''),
'systemctl is-enabled s-disabled.service': (1, '', ''),
'journalctl -u s-disabled.service': (0, '-- No entries --', ''),
'systemctl enable s-disabled.service': (0, '', ''),
'systemctl disable s-enabled.service': (0, '', ''),
'systemctl status s-running.service': (0, '', ''),
'systemctl status s-stopped.service': (1, '', ''),
'journalctl -u s-stopped.service': (0, '-- No entries --', ''),
'systemctl start s-stopped.service': (0, '', ''),
'systemctl start s-running.service': (1, '', ''),
'journalctl -u s-running.service': (0, '-- No entries --', ''),
'systemctl stop s-stopped.service': (1, '', ''),
'journalctl -u s-stopped.service': (0, '-- No entries --', ''),
'systemctl stop s-running.service': (0, '', ''),
'systemctl restart s-running.service': (0, '', ''),
'systemctl reload s-running.service': (0, '', ''),
Expand Down

0 comments on commit 302e398

Please sign in to comment.