-
Notifications
You must be signed in to change notification settings - Fork 2
/
dpcmder.go
37 lines (31 loc) · 1.03 KB
/
dpcmder.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Package main is entrypoint to DataPower commander (dpcmder) application.
package main
import (
"os"
"os/signal"
"syscall"
"github.com/croz-ltd/dpcmder/config"
"github.com/croz-ltd/dpcmder/ui"
"github.com/croz-ltd/dpcmder/utils/logging"
)
func main() {
config.Init()
config.PrintConfig()
setupCloseHandler()
ui.Start()
logging.LogDebug("main/main() - ...dpcmder ending.")
}
// setupCloseHandler creates a 'listener' on a new goroutine which will notify the
// program if it receives an interrupt from the OS. Since tcell input catch Ctrl+C
// it probably comes from Ctrl+C combination sent to external program - ignoring it.
func setupCloseHandler() {
c := make(chan os.Signal, 2)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
signal.Notify(c, os.Interrupt, syscall.SIGKILL)
signal.Notify(c, os.Interrupt, syscall.SIGINT)
signal.Notify(c, os.Interrupt, syscall.SIGHUP)
go func() {
s := <-c
logging.LogDebug("main/setupCloseHandler() - System interrupt signal received from external program, ignoring it - s: ", s)
}()
}