-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
37 lines (31 loc) · 788 Bytes
/
main.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
import (
"flag"
"os"
"os/signal"
"syscall"
)
func main() {
configFile := flag.String("config", "./srsd.json", "File containing configuration options")
socketPath := flag.String("socket", "./srsd.sock", "Path to the socket file to listen on")
socketAccess := flag.Uint("socket-access", 0770, "Access permissions to set for the socket file")
flag.Parse()
config, err := loadConfig(*configFile)
if err != nil {
panic(err)
}
srsd, err := newSrsd(config, *socketPath, os.FileMode(*socketAccess))
if err != nil {
panic(err)
}
signals := make(chan os.Signal, 1)
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)
go func() {
for _ = range signals {
srsd.close()
os.Exit(1)
}
}()
defer srsd.close()
srsd.run()
}