mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-20 09:39:08 +00:00
Merge pull request #3920 from vouch-opensource/fix/service-restarts-with-memlogd
Allow service restarts when using memlogd
This commit is contained in:
commit
b26c169797
@ -100,7 +100,14 @@ type remoteLog struct {
|
|||||||
// Path returns the name of a FIFO connected to the logging daemon.
|
// Path returns the name of a FIFO connected to the logging daemon.
|
||||||
func (r *remoteLog) Path(n string) string {
|
func (r *remoteLog) Path(n string) string {
|
||||||
path := filepath.Join(r.fifoDir, n+".log")
|
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 {
|
if err := syscall.Mkfifo(path, 0600); err != nil {
|
||||||
|
log.Printf("failed to create fifo %s: %s", path, err)
|
||||||
return "/dev/null"
|
return "/dev/null"
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
|
Loading…
Reference in New Issue
Block a user