forked from External/grumble
Improved logging.
This commit is contained in:
parent
244027d41b
commit
b13dbeadf1
6 changed files with 82 additions and 6 deletions
|
|
@ -5,6 +5,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
)
|
||||
|
|
@ -12,9 +13,17 @@ import (
|
|||
func SignalHandler() {
|
||||
for {
|
||||
sig := <-signal.Incoming
|
||||
if sig != os.SIGINT && sig != os.SIGTERM {
|
||||
|
||||
if sig == os.SIGUSR2 {
|
||||
err := LogTarget.Rotate()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Unable to rotate log file: %v", err)
|
||||
}
|
||||
continue
|
||||
}
|
||||
os.Exit(0)
|
||||
|
||||
if sig == os.SIGINT || sig == os.SIGTERM {
|
||||
os.Exit(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue