-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
54 lines (43 loc) · 1.24 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
/**
* rastermimimi reads calendar data from various sources and displays then as html.
*/
package main
import (
"flag"
"log"
"os"
"strconv"
_ "time/tzdata"
)
func main() {
// get config from flags and environment using flag.Parse and os.Getenv
listenAddr := flag.String("listen-addr", getenv("MIMIMI_LISTEN_ADDR", ":8080"), "listen address")
websiteURL := flag.String("url", getenv("MIMIMI_WEBSITE_URL", "https://rabe.ch"), "URL of RaBe Website")
libretimeURL := flag.String("libretime", getenv("MIMIMI_LIBRETIME_URL", "https://airtime.service.int.rabe.ch"), "URL of Libretime Instance to compare")
durationDefault, error := strconv.Atoi(getenv("MIMIMI_DURATION", "60"))
if error != nil {
log.Fatal("MIMIMI_DURATION must be an integer")
}
duration := flag.Int("duration", durationDefault, "How far ahead to check in days")
flag.Parse()
// configure and run app and server
app := NewApp(
AppConfig{
duration: *duration,
websiteURL: *websiteURL,
libretimeURL: *libretimeURL,
listenAddr: *listenAddr,
},
)
app.Load()
server := NewServer(app)
server.Setup()
log.Fatal(server.ListenAndServe())
}
func getenv(key, fallback string) string {
value := fallback
if v := os.Getenv(key); v != "" {
value = v
}
return value
}