-
Notifications
You must be signed in to change notification settings - Fork 3
/
events.go
45 lines (35 loc) · 974 Bytes
/
events.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
38
39
40
41
42
43
44
45
package events
import (
"os"
"os/signal"
"sync"
"github.com/cskr/pubsub"
)
// Event channel names used for event Pubsub
// internal
const (
MqttConnStatus = "mqttConnStatus" // int
ForwardCat = "forwardAudio" //bool
CliInput = "cliInput" // []string
PrepareShutdown = "prepShutdown" // no type
Shutdown = "shutdown" // no type
OsExit = "osExit" // bool
AppLog = "applog" // string
RadioLog = "radiolog" // string
RadioOnline = "radioOnline" //bool
Pong = "pong" // int64
)
func WatchSystemEvents(evPS *pubsub.PubSub, wg *sync.WaitGroup) {
defer wg.Done()
// Channel to handle OS signals
osSignals := make(chan os.Signal, 1)
//subscribe to os.Interrupt (CTRL-C signal)
signal.Notify(osSignals, os.Interrupt)
select {
case osSignal := <-osSignals:
if osSignal == os.Interrupt {
evPS.Pub(true, PrepareShutdown)
return
}
}
}