aboutsummaryrefslogtreecommitdiff
path: root/haminer.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2022-08-17 13:38:18 +0700
committerShulhan <ms@kilabit.info>2022-08-17 13:38:18 +0700
commite09855572bece218df45df61c2eb8a106a9ef8de (patch)
treea8387e92eaac348165d44409b525665d83c2d32c /haminer.go
parent05b4830d0fd5aaec157139d88beffa1cf0ce0615 (diff)
downloadhaminer-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.go15
1 files changed, 0 insertions, 15 deletions
diff --git a/haminer.go b/haminer.go
index 45c15c7..256a068 100644
--- a/haminer.go
+++ b/haminer.go
@@ -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 {