Skip to content

Commit

Permalink
Fix issue with systemd inactive status. (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
blakerouse committed Nov 16, 2020
1 parent a91b404 commit 60dcbae
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion service_systemd_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,17 @@ func (s *systemd) Status() (Status, error) {
case strings.HasPrefix(out, "active"):
return StatusRunning, nil
case strings.HasPrefix(out, "inactive"):
return StatusStopped, nil
// inactive can also mean its not installed, check unit files
exitCode, out, err := runWithOutput("systemctl", "list-unit-files", "-t", "service", s.Name)
if exitCode == 0 && err != nil {
return StatusUnknown, err
}
if strings.Contains(out, s.Name) {
// unit file exists, installed but not running
return StatusStopped, nil
}
// no unit file
return StatusUnknown, ErrNotInstalled
case strings.HasPrefix(out, "activating"):
return StatusRunning, nil
case strings.HasPrefix(out, "failed"):
Expand Down

0 comments on commit 60dcbae

Please sign in to comment.