-
Notifications
You must be signed in to change notification settings - Fork 4
/
gudgeon.go
65 lines (53 loc) · 1.35 KB
/
gudgeon.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"github.com/chrisruffalo/gudgeon/config"
"github.com/chrisruffalo/gudgeon/engine"
"github.com/chrisruffalo/gudgeon/provider"
"github.com/chrisruffalo/gudgeon/util"
)
// pick up version from build process
var Version = "1.0.0"
var GitHash = "000000"
var LongVersion = Version + "@git" + GitHash
func main() {
// load command options
opts, err := config.Options(LongVersion)
if err != nil {
fmt.Printf("%s\n", err)
os.Exit(1)
}
// load config
config, err := config.Load(string(opts.AppOptions.ConfigPath))
if err != nil {
fmt.Printf("%s\n", err)
os.Exit(1)
}
// debug print config
fmt.Printf("Gudgeon %s\n===============================\n", LongVersion)
// clean out session directory
if "" != config.SessionRoot() {
util.ClearDirectory(config.SessionRoot())
}
// prepare engine with config options
engine, err := engine.New(config)
if err != nil {
fmt.Printf("%s\n", err)
os.Exit(1)
}
// create a new provider and start hosting
provider := provider.NewProvider()
provider.Host(config, engine)
// wait for signal
sig := make(chan os.Signal)
signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM)
s := <-sig
// clean out session directory
if "" != config.SessionRoot() {
util.ClearDirectory(config.SessionRoot())
}
fmt.Printf("Signal (%s) received, stopping\n", s)
}