mirror of
https://github.com/mumble-voip/grumble.git
synced 2025-12-19 21:59:59 -08:00
30 lines
665 B
Go
30 lines
665 B
Go
// Copyright (c) 2011 The Grumble Authors
|
|
// The use of this source code is goverened by a BSD-style
|
|
// license that can be found in the LICENSE-file.
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"mumbleapp.com/grumble/pkg/logtarget"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
)
|
|
|
|
func SignalHandler() {
|
|
sigchan := make(chan os.Signal, 10)
|
|
signal.Notify(sigchan, syscall.SIGUSR2, syscall.SIGTERM, syscall.SIGINT)
|
|
for sig := range sigchan {
|
|
if sig == syscall.SIGUSR2 {
|
|
err := logtarget.Target.Rotate()
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "unable to rotate log file: %v", err)
|
|
}
|
|
continue
|
|
}
|
|
if sig == syscall.SIGINT || sig == syscall.SIGTERM {
|
|
os.Exit(0)
|
|
}
|
|
}
|
|
}
|