diff options
| author | Shulhan <ms@kilabit.info> | 2022-08-17 13:38:18 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2022-08-17 13:38:18 +0700 |
| commit | e09855572bece218df45df61c2eb8a106a9ef8de (patch) | |
| tree | a8387e92eaac348165d44409b525665d83c2d32c /haminer.go | |
| parent | 05b4830d0fd5aaec157139d88beffa1cf0ce0615 (diff) | |
| download | haminer-e09855572bece218df45df61c2eb8a106a9ef8de.tar.xz | |
all: move handling signal to main program
It is up to the user of haminer library (in this case the cmd/haminer)
on how to Start and Stop the process, not at the library level.
Diffstat (limited to 'haminer.go')
| -rw-r--r-- | haminer.go | 15 |
1 files changed, 0 insertions, 15 deletions
@@ -8,9 +8,6 @@ import ( "fmt" "log" "net" - "os" - "os/signal" - "syscall" "time" ) @@ -18,7 +15,6 @@ import ( type Haminer struct { cfg *Config udpConn *net.UDPConn - chSignal chan os.Signal chHttpLog chan *HttpLog ff []Forwarder isRunning bool @@ -33,14 +29,10 @@ func NewHaminer(cfg *Config) (h *Haminer) { h = &Haminer{ cfg: cfg, - chSignal: make(chan os.Signal, 1), chHttpLog: make(chan *HttpLog, 30), ff: make([]Forwarder, 0), } - signal.Notify(h.chSignal, syscall.SIGHUP, syscall.SIGINT, - syscall.SIGTERM, syscall.SIGQUIT) - h.createForwarder() return @@ -75,11 +67,6 @@ func (h *Haminer) Start() (err error) { go h.consume() go h.produce() - - <-h.chSignal - - h.Stop() - return } @@ -171,8 +158,6 @@ func (h *Haminer) produce() { func (h *Haminer) Stop() { h.isRunning = false - signal.Stop(h.chSignal) - if h.udpConn != nil { err := h.udpConn.Close() if err != nil { |
