-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathmain.go
More file actions
64 lines (53 loc) · 1.16 KB
/
main.go
File metadata and controls
64 lines (53 loc) · 1.16 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"goshs.de/goshs/v2/config"
"goshs.de/goshs/v2/logger"
"goshs.de/goshs/v2/options"
"goshs.de/goshs/v2/sanity"
"goshs.de/goshs/v2/server"
)
func main() {
var err error
// flags
opts, print := options.Parse()
// Print config
if print {
config, err := config.PrintExample()
if err != nil {
panic(err)
}
fmt.Println(config)
os.Exit(0)
}
// Load config
if opts.ConfigFile != "" {
opts, err = config.LoadConfig(opts)
if err != nil {
logger.Fatalf("Failed to load config: %+v", err)
}
}
// Sanitize webroot and check sanity
opts, err = sanity.Sanitize(opts)
if err != nil {
logger.Fatalf("Failed to sanitize webroot: %+v", err)
}
opts, err = sanity.Check(opts)
if err != nil {
logger.Fatalf("Sanity check failed: %+v", err)
}
// Further processing of options
opts, err = sanity.FurtherProcessing(opts)
if err != nil {
logger.Fatalf("Further processing failed: %+v", err)
}
// Start all server
server.StartAll(opts)
done := make(chan os.Signal, 1)
signal.Notify(done, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
<-done
logger.Infof("Received CTRL+C, exiting...")
}