mirror of
https://github.com/wneessen/logranger.git
synced 2024-11-25 14:20:49 +01:00
Refactor signal handling and remove SPDX licensing details
Redid signal handling in the main server code leading to simpler, more readable code. Removed the SPDX license identifiers from 'go.sum' following recent policy changes.
This commit is contained in:
parent
ea1ac393bc
commit
436df7b2b4
2 changed files with 21 additions and 28 deletions
|
@ -45,31 +45,28 @@ func main() {
|
|||
|
||||
sc := make(chan os.Signal, 1)
|
||||
signal.Notify(sc)
|
||||
for {
|
||||
select {
|
||||
case rc := <-sc:
|
||||
if rc == syscall.SIGKILL || rc == syscall.SIGABRT || rc == syscall.SIGINT || rc == syscall.SIGTERM {
|
||||
l.Warn("received signal. shutting down server", slog.String("signal", rc.String()))
|
||||
//s.Stop()
|
||||
l.Info("server gracefully shut down")
|
||||
os.Exit(0)
|
||||
}
|
||||
if rc == syscall.SIGHUP {
|
||||
l.Info(`received "SIGHUP" signal - reloading rules...`)
|
||||
/*
|
||||
_, nr, err := config.New(config.WithConfFile(*cf), config.WithRulesFile(*rf))
|
||||
if err != nil {
|
||||
s.Log.Errorf("%s - skipping reload", err)
|
||||
continue
|
||||
}
|
||||
if err := nr.CheckRegEx(); err != nil {
|
||||
s.Log.Errorf("ruleset validation failed for new ruleset - skipping reload: %s", err)
|
||||
continue
|
||||
}
|
||||
s.SetRules(nr)
|
||||
for rc := range sc {
|
||||
if rc == syscall.SIGKILL || rc == syscall.SIGABRT || rc == syscall.SIGINT || rc == syscall.SIGTERM {
|
||||
l.Warn("received signal. shutting down server", slog.String("signal", rc.String()))
|
||||
// s.Stop()
|
||||
l.Info("server gracefully shut down")
|
||||
os.Exit(0)
|
||||
}
|
||||
if rc == syscall.SIGHUP {
|
||||
l.Info(`received "SIGHUP" signal - reloading rules...`)
|
||||
/*
|
||||
_, nr, err := config.New(config.WithConfFile(*cf), config.WithRulesFile(*rf))
|
||||
if err != nil {
|
||||
s.Log.Errorf("%s - skipping reload", err)
|
||||
continue
|
||||
}
|
||||
if err := nr.CheckRegEx(); err != nil {
|
||||
s.Log.Errorf("ruleset validation failed for new ruleset - skipping reload: %s", err)
|
||||
continue
|
||||
}
|
||||
s.SetRules(nr)
|
||||
|
||||
*/
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
4
go.sum
4
go.sum
|
@ -1,7 +1,3 @@
|
|||
// SPDX-FileCopyrightText: 2023 Winni Neessen <wn@neessen.dev>
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
|
|
Loading…
Reference in a new issue