Skip to content

Commit

Permalink
Remove error handling fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonBaeumer committed Feb 12, 2019
1 parent a98fce7 commit 48b0a6a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 28 deletions.
5 changes: 1 addition & 4 deletions system/addr.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ func (a *DefAddr) Reachable() (bool, error) {
if err != nil {
return false, nil
}

if err = conn.Close(); err != nil {
return false, err
}
conn.Close()
return true, nil
}

Expand Down
6 changes: 1 addition & 5 deletions system/service_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,8 @@ func (s *ServiceInit) Running() (bool, error) {
if invalidService(s.service) {
return false, nil
}

cmd := util.NewCommand("service", s.service, "status")
if err := cmd.Run(); err != nil {
return false, err
}

cmd.Run()
if cmd.Status == 0 {
return true, cmd.Err
}
Expand Down
17 changes: 3 additions & 14 deletions system/service_systemd.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@ func (s *ServiceSystemd) Exists() (bool, error) {
if invalidService(s.service) {
return false, nil
}

cmd := util.NewCommand("systemctl", "-q", "list-unit-files", "--type=service")
if err := cmd.Run(); err != nil {
return false, err
}

cmd.Run()
if strings.Contains(cmd.Stdout.String(), fmt.Sprintf("%s.service", s.service)) {
return true, cmd.Err
}
Expand All @@ -47,10 +43,7 @@ func (s *ServiceSystemd) Enabled() (bool, error) {
return false, nil
}
cmd := util.NewCommand("systemctl", "-q", "is-enabled", s.service)
if err := cmd.Run(); err != nil {
return false, err
}

cmd.Run()
if cmd.Status == 0 {
return true, cmd.Err
}
Expand All @@ -66,12 +59,8 @@ func (s *ServiceSystemd) Running() (bool, error) {
if invalidService(s.service) {
return false, nil
}

cmd := util.NewCommand("systemctl", "-q", "is-active", s.service)
if err := cmd.Run(); err != nil {
return false, err
}

cmd.Run()
if cmd.Status == 0 {
return true, cmd.Err
}
Expand Down
6 changes: 1 addition & 5 deletions system/service_upstart.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ func (s *ServiceUpstart) Enabled() (bool, error) {

func (s *ServiceUpstart) Running() (bool, error) {
cmd := util.NewCommand("service", s.service, "status")
err := cmd.Run()
if err != nil {
return false, err
}

cmd.Run()
out := cmd.Stdout.String()
if cmd.Status == 0 && (strings.Contains(out, "running") || strings.Contains(out, "online")) {
return true, cmd.Err
Expand Down

0 comments on commit 48b0a6a

Please sign in to comment.