Skip to content

Commit

Permalink
print logging config on service status
Browse files Browse the repository at this point in the history
  • Loading branch information
sigmonsays committed Jan 23, 2016
1 parent 4feed5a commit 49a6e47
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cmd/runitcmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,19 @@ func (app *Application) Status(c *cli.Context) {
fmt.Printf("enabled %v\n", st.Enabled)
fmt.Printf("activated %v\n", st.Activated)
fmt.Printf("\n")
if cfg, err := service.Config(); err == nil {
l := cfg.Logging
if l != nil {
fmt.Printf("logging:\n")
fmt.Printf("directory %s\n", l.Directory)
fmt.Printf("max size %d bytes\n", l.Size)
fmt.Printf("number %d\n", l.Num)
fmt.Printf("timeout %d seconds\n", l.Timeout)
fmt.Printf("minimum %d\n", l.Min)
fmt.Printf("\n")
}
} else {
fmt.Printf("logging configuration unavailable\n")
}
}
}
11 changes: 11 additions & 0 deletions runit/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package runit
import (
"io/ioutil"
"os"
"path/filepath"

"gopkg.in/yaml.v2"
)
Expand Down Expand Up @@ -48,3 +49,13 @@ func (c *ServiceConfig) SaveFile(path string) error {
err = os.Rename(tmppath, path)
return err
}

func (s *Service) Config() (*ServiceConfig, error) {
cfgfile := filepath.Join(s.ServiceDir, "service.yaml")
c := &ServiceConfig{}
err := c.LoadFile(cfgfile)
if err != nil {
return nil, err
}
return c, nil
}

0 comments on commit 49a6e47

Please sign in to comment.