Skip to content

Commit

Permalink
Merge pull request #3920 from vouch-opensource/fix/service-restarts-w…
Browse files Browse the repository at this point in the history
…ith-memlogd

Allow service restarts when using memlogd
  • Loading branch information
deitch committed Nov 14, 2023
2 parents bbd9b85 + 247d919 commit b26c169
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/init/cmd/service/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,14 @@ type remoteLog struct {
// Path returns the name of a FIFO connected to the logging daemon.
func (r *remoteLog) Path(n string) string {
path := filepath.Join(r.fifoDir, n+".log")
// replicate behavior of os.Create(path) for a fileLog.
// if a file exists at the given path, os.Create will truncate it.
// syscall.Mkfifo on the other hand fails when a file exists at the given path.
if _, err := os.Stat(path); err == nil {
os.Remove(path)
}
if err := syscall.Mkfifo(path, 0600); err != nil {
log.Printf("failed to create fifo %s: %s", path, err)
return "/dev/null"
}
go func() {
Expand Down

0 comments on commit b26c169

Please sign in to comment.