Skip to content

Commit

Permalink
Discard getServiceStatus logging to avoid log explosion (#61)
Browse files Browse the repository at this point in the history
Querying the service status can happen any number of times between
service 'start's.  Since log truncating only happens on start, this
can cause unchecked growth of service loggers.
  • Loading branch information
cbrockington authored and dansanduleac committed Oct 9, 2018
1 parent c6f0586 commit 3da1eec
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
13 changes: 13 additions & 0 deletions init/cli/logging.go
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package cli
import (
"fmt"
"io"
"io/ioutil"
"os"

"github.com/pkg/errors"
Expand Down Expand Up @@ -78,3 +79,15 @@ func (f *FileLoggers) OpenFile(path string) (*os.File, error) {
}
return file, nil
}

var devNull = launchlib.NoopClosingWriter{Writer: ioutil.Discard}

type DevNullLoggers struct{}

func (d *DevNullLoggers) PrimaryLogger() (io.WriteCloser, error) {
return &devNull, nil
}

func (d *DevNullLoggers) SubProcessLogger(name string) launchlib.CreateLogger {
return d.PrimaryLogger
}
3 changes: 2 additions & 1 deletion init/cli/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ If exit code is nonzero, writes an error message to stderr and var/log/startup.l
}

func status(ctx cli.Context, loggers launchlib.ServiceLoggers) error {
serviceStatus, err := getServiceStatus(ctx, loggers)
// Executed with logging for errors, however we discard the verbose logging of getServiceStatus
serviceStatus, err := getServiceStatus(ctx, &DevNullLoggers{})
if err != nil {
return logErrorAndReturnWithExitCode(ctx, errors.Wrap(err, "failed to determine service status"), 4)
}
Expand Down
Empty file added integration_test/-
Empty file.

0 comments on commit 3da1eec

Please sign in to comment.