mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-22 10:31:35 +00:00
vsudd: Log over syslog
This means that with the previous patches normal vsudd logging will be logged
on the console. The exceptional case of error logging during syslog forwarding
established in the previous patch remains in place.
Prior to this the vsudd.log was actually in /run/vsudd.log and not in /var/log/
(exported to the host) as expected. Prior to c5940b3479
("Bind the original
/var/log onto /run/log") the log was simply shadowed under the fuse mount over
/var/log.
Signed-off-by: Ian Campbell <ian.campbell@docker.com>
This commit is contained in:
parent
7dd7b0c0da
commit
ad7f4c74b2
@ -20,7 +20,6 @@ start()
|
||||
fi
|
||||
|
||||
[ -n "${PIDFILE}" ] || PIDFILE=/var/run/vsudd.pid
|
||||
[ -n "${LOGFILE}" ] || LOGFILE=/var/log/vsudd.log
|
||||
|
||||
if [ -n "$SYSLOG_PORT" ] ; then
|
||||
# Can be inlined below once Windows defines syslog port
|
||||
@ -31,9 +30,9 @@ start()
|
||||
--background \
|
||||
--exec /sbin/vsudd \
|
||||
--make-pidfile --pidfile ${PIDFILE} \
|
||||
--stderr "${LOGFILE}" --stdout "${LOGFILE}" \
|
||||
-- -inport "${DOCKER_PORT}:unix:/var/run/docker.sock" \
|
||||
${SYSLOG_OPT}
|
||||
${SYSLOG_OPT} \
|
||||
-detach
|
||||
|
||||
eend $? "Failed to start vsudd"
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"log/syslog"
|
||||
"net"
|
||||
"os"
|
||||
"strconv"
|
||||
@ -66,15 +67,24 @@ func main() {
|
||||
flag.Parse()
|
||||
|
||||
if detach {
|
||||
logFile, err := os.Create("/var/log/vsudd.log")
|
||||
syslog, err := syslog.New(syslog.LOG_INFO|syslog.LOG_DAEMON, "vsudd")
|
||||
if err != nil {
|
||||
log.Fatalln("Failed to open log file", err)
|
||||
log.Fatalln("Failed to open syslog", err)
|
||||
}
|
||||
log.SetOutput(logFile)
|
||||
|
||||
null, err := os.OpenFile("/dev/null", os.O_RDWR, 0)
|
||||
if err != nil {
|
||||
log.Fatalln("Failed to open /dev/null", err)
|
||||
}
|
||||
|
||||
/* Don't do this above since we aren't yet forwarding
|
||||
/* syslog (if we've been asked to) so the above error
|
||||
/* reporting wants to go via the default path
|
||||
/* (stdio). */
|
||||
|
||||
log.SetOutput(syslog)
|
||||
log.SetFlags(0)
|
||||
|
||||
fd := null.Fd()
|
||||
syscall.Dup2(int(fd), int(os.Stdin.Fd()))
|
||||
syscall.Dup2(int(fd), int(os.Stdout.Fd()))
|
||||
|
Loading…
Reference in New Issue
Block a user