mirror of
https://github.com/foxcpp/maddy.git
synced 2025-04-04 13:37:41 +03:00
Make maddy buildable with GOOS=windows
Some people want to do so (#83) and it is not a big trouble for us to support it.
This commit is contained in:
parent
5eeace2ffa
commit
97b370191d
6 changed files with 83 additions and 28 deletions
25
maddy.go
25
maddy.go
|
@ -2,9 +2,6 @@ package maddy
|
|||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/foxcpp/maddy/config"
|
||||
"github.com/foxcpp/maddy/log"
|
||||
|
@ -100,27 +97,7 @@ func Start(cfg []config.Node) error {
|
|||
}
|
||||
}
|
||||
|
||||
sig := make(chan os.Signal, 5)
|
||||
signal.Notify(sig, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP, syscall.SIGINT, syscall.SIGUSR1)
|
||||
|
||||
for {
|
||||
switch s := <-sig; s {
|
||||
case syscall.SIGUSR1:
|
||||
log.Println("SIGUSR1 received, reinitializing logging")
|
||||
reinitLogging()
|
||||
default:
|
||||
log.Printf("signal received (%v), next signal will force immediate shutdown.", s)
|
||||
// break inside switch exits switch, not outer loop
|
||||
goto exitsigloop
|
||||
}
|
||||
}
|
||||
exitsigloop:
|
||||
|
||||
go func() {
|
||||
s := <-sig
|
||||
log.Printf("forced shutdown due to signal (%v)!", s)
|
||||
os.Exit(1)
|
||||
}()
|
||||
waitForSignal()
|
||||
|
||||
for _, inst := range instances {
|
||||
if closer, ok := inst.instance.(io.Closer); ok {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue