forked from rosenhouse/ifg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (35 loc) · 737 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
38
39
40
41
42
43
package main
import (
"fmt"
"os"
"time"
"github.com/rosenhouse/ifg/application"
)
func main() {
config := application.Config{
RootPath: LoadOrFail("ROOT_PATH"),
Port: LoadOrFail("PORT"),
VCAPServices: LoadOrFail("VCAP_SERVICES"),
}
app, err := application.NewApplication(config)
if err != nil {
Fail(err.Error())
}
err = app.Boot()
if err != nil {
Fail(err.Error())
}
}
func LoadOrFail(variable string) string {
value := os.Getenv(variable)
if value == "" {
Fail("'%s' is a required environment variable", variable)
}
return value
}
func Fail(format string, a ...interface{}) {
time.Sleep(3 * time.Second)
fmt.Fprintf(os.Stderr, format, a...)
fmt.Fprintf(os.Stderr, "\n")
os.Exit(1)
}