Skip to content

Commit

Permalink
chore: refactor (#39)
Browse files Browse the repository at this point in the history
* feat: support connection stats

* chore: refactor
  • Loading branch information
kevwan authored May 6, 2023
1 parent 6a555eb commit c713ba7
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,18 @@ func NewStater(staters ...Stater) Stater {
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)

for {
select {
case sig := <-c:
signal.Stop(c)
stat.Stop()

p, err := os.FindProcess(syscall.Getpid())
if err != nil {
fmt.Println(err)
os.Exit(0)
}

if err := p.Signal(sig); err != nil {
fmt.Println(err)
}
for sig := range c {
signal.Stop(c)
stat.Stop()

p, err := os.FindProcess(syscall.Getpid())
if err != nil {
fmt.Println(err)
os.Exit(0)
}

if err := p.Signal(sig); err != nil {
fmt.Println(err)
}
}
}()
Expand Down

0 comments on commit c713ba7

Please sign in to comment.