fix logging for backend

This commit is contained in:
Ted Unangst 2022-02-09 16:30:58 -05:00
parent bbefe801d3
commit de7ff1ed98
3 changed files with 12 additions and 1 deletions

View File

@ -104,7 +104,7 @@ func backendServer() {
}
func runBackendServer() {
proc := exec.Command(os.Args[0], "-datadir", dataDir, "backend")
proc := exec.Command(os.Args[0], reexecArgs("backend")...)
proc.Stdout = os.Stdout
proc.Stderr = os.Stderr
err := proc.Start()

View File

@ -259,6 +259,13 @@ func unplugserver(hostname string) {
db.Exec("delete from doovers where rcpt like ?", xid)
}
func reexecArgs(cmd string) []string {
args := []string{"-datadir", dataDir}
args = append(args, loggingArgs()...)
args = append(args, cmd)
return args
}
func main() {
flag.StringVar(&dataDir, "datadir", dataDir, "data directory")
flag.StringVar(&viewDir, "viewdir", viewDir, "view directory")

4
log.go
View File

@ -42,6 +42,10 @@ func init() {
}
func loggingArgs() []string {
return []string{"-errorlog", elogname, "-infolog", ilogname, "-debuglog", dlogname}
}
func initLogging(elogname, ilogname, dlogname string) {
elog = openlog(elogname, syslog.LOG_ERR)
ilog = openlog(ilogname, syslog.LOG_INFO)