Skip to content

Commit

Permalink
Cleanup issues
Browse files Browse the repository at this point in the history
* Init Go modules
* Cleanup linter warnings.

Signed-off-by: SuperQ <[email protected]>
  • Loading branch information
SuperQ committed May 9, 2023
1 parent 06ad41a commit 55c5814
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/prometheus-community/go-runit

go 1.20
17 changes: 2 additions & 15 deletions runit/runit.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package runit
import (
"errors"
"fmt"
"io/ioutil"
"os"
"syscall"
"time"
Expand Down Expand Up @@ -55,13 +54,13 @@ func GetServices(dir string) ([]*service, error) {
if dir == "" {
dir = defaultServiceDir
}
files, err := ioutil.ReadDir(dir)
files, err := os.ReadDir(dir)
if err != nil {
return nil, err
}
services := []*service{}
for _, file := range files {
if file.Mode()&os.ModeSymlink == os.ModeSymlink || file.IsDir() {
if file.Type() == os.ModeSymlink || file.IsDir() {
services = append(services, GetService(file.Name(), dir))
}
}
Expand All @@ -80,18 +79,6 @@ func (s *service) file(file string) string {
return fmt.Sprintf("%s/%s/supervise/%s", s.ServiceDir, s.Name, file)
}

func (s *service) runsvRunning() (bool, error) {
file, err := os.OpenFile(s.file("ok"), os.O_WRONLY, 0)
if err != nil {
if err == syscall.ENXIO {
return false, nil
}
return false, err
}
file.Close()
return true, nil
}

func (s *service) status() ([]byte, error) {
file, err := os.Open(s.file("status"))
if err != nil {
Expand Down

0 comments on commit 55c5814

Please sign in to comment.