This repository has been archived by the owner on Mar 26, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exec the ulogd daemon on weave-npc startup, copying any log output to our own logs. Exit if the ulogd process terminates for any reason.
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package ulogd | ||
|
||
import ( | ||
log "github.com/Sirupsen/logrus" | ||
"io" | ||
"os" | ||
"os/exec" | ||
) | ||
|
||
func waitForExit(cmd *exec.Cmd) { | ||
if err := cmd.Wait(); err != nil { | ||
log.Fatalf("ulogd terminated: %v", err) | ||
} | ||
log.Fatal("ulogd terminated normally") | ||
} | ||
|
||
func Start() error { | ||
cmd := exec.Command("/usr/sbin/ulogd", "-v") | ||
stdout, err := cmd.StderrPipe() | ||
if err != nil { | ||
return err | ||
} | ||
if err := cmd.Start(); err != nil { | ||
return err | ||
} | ||
go io.Copy(os.Stdout, stdout) | ||
go waitForExit(cmd) | ||
return nil | ||
} |