/
goshipit.go
55 lines (47 loc) · 1.09 KB
/
goshipit.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
package main
import (
"github.com/aphistic/gomol"
"github.com/quakkels/goshipit/context"
"github.com/quakkels/goshipit/controllers"
"github.com/quakkels/goshipit/images"
"github.com/quakkels/goshipit/slack"
"net/http"
"os"
"strconv"
)
func main() {
startUp()
defer cleanUp()
// get context from args
args := os.Args[1:]
if len(args) == 3 {
isSecure, err := strconv.ParseBool(args[2])
if err != nil {
panic("isSecure cli argument is not boolean.")
}
context.SetContext(args[0], args[1], isSecure)
}
err := images.InitImages()
if err != nil {
gomol.Fatal("Could not load images.json.")
panic(err)
}
err = slack.InitSlackConfig()
if err != nil {
gomol.Fatal("Could not load slack.json.")
panic(err)
}
controllers.Register()
http.ListenAndServe(":"+context.Port, nil)
}
func startUp() {
loggerConfig := gomol.NewConsoleLoggerConfig()
consoleLogger, _ := gomol.NewConsoleLogger(loggerConfig)
gomol.AddLogger(consoleLogger)
gomol.InitLoggers()
gomol.Info("Initialized console logger")
}
func cleanUp() {
gomol.Info("Shutting down loggers")
gomol.ShutdownLoggers()
}