mirror of
https://github.com/mumble-voip/grumble.git
synced 2025-12-22 02:51:57 -08:00
Rename and move everything to hopefully make it possible to use this package as a Golang package
This commit is contained in:
parent
4a90b31d8d
commit
050b578821
23 changed files with 74 additions and 204 deletions
33
server/signal_unix.go
Normal file
33
server/signal_unix.go
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
// 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.
|
||||
|
||||
// +build darwin freebsd linux netbsd openbsd
|
||||
|
||||
package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/digitalautonomy/grumble/pkg/logtarget"
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue