-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
45 lines (35 loc) · 879 Bytes
/
main.go
File metadata and controls
45 lines (35 loc) · 879 Bytes
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 main is the main package for the Fogwillow application.
package main
import (
"flag"
"log"
"os"
"os/signal"
"syscall"
"github.com/Notifiarr/fogwillow/pkg/fog"
)
func main() {
configFile := flag.String("config", "/config/fog.conf", "config file path")
flag.Parse()
// Load configuration file.
fog, err := fog.LoadConfigFile(*configFile)
if err != nil {
log.Fatalf("Config File Error: %s", err)
}
go catchSignal(fog)
err = fog.Start()
if err != nil {
log.Fatalf("Starting Fog Failed: %v", err)
}
fog.Printf("Done. Good bye!")
}
func catchSignal(fog *fog.Config) {
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, os.Interrupt, syscall.SIGTERM)
// Wait here for a signal to shut down.
fog.Printf("Shutting down! Caught signal: %s", <-sigCh)
err := fog.Shutdown()
if err != nil {
log.Fatalf("Stopping Fog Failed: %v", err)
}
}