-
Notifications
You must be signed in to change notification settings - Fork 17
/
main.go
68 lines (54 loc) · 1.89 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
Copyright (C) 2018 Expedia Group.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"fmt"
"github.com/ExpediaGroup/flyte/pack"
"github.com/ExpediaGroup/flyte/server"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"net/http"
"os"
"strings"
)
func main() {
out := zerolog.ConsoleWriter{
NoColor: true,
Out: os.Stdout,
TimeFormat: "2006-01-02T15:04:05.999",
}
out.PartsOrder = []string{"level", "time", "message"}
out.FormatLevel = func(i interface{}) string {
return strings.ToUpper(fmt.Sprintf("[%s]", i))
}
log.Logger = log.Output(out)
c := NewConfig()
if c.ShouldDeleteDeadPacks {
log.Info().Msgf("daily removal of dead packs is scheduled to run at '%s' set with a grace period of '%v' seconds.", c.DeleteDeadPacksTime, c.PackGracePeriodUntilDeadInSeconds)
pack.ScheduleDailyRemovalOfDeadPacksAt(c.DeleteDeadPacksTime, c.PackGracePeriodUntilDeadInSeconds)
}
flyteServer := server.NewFlyteServer(c.Port, c.MongoHost, c.FlyteTTL)
if c.requireAuth() {
flyteServer.EnableAuth(c.AuthPolicyPath, c.OidcIssuerURL, c.OidcIssuerClientID)
}
log.Info().Msgf("Serving flyteapi on %s with TLS %v", flyteServer.Addr, c.requireTLS())
var err error
if c.requireTLS() {
err = flyteServer.ListenAndServeTLS(c.TLSCertPath, c.TLSKeyPath)
} else {
err = flyteServer.ListenAndServe()
}
if err != nil && err != http.ErrServerClosed {
log.Fatal().Msgf("flyteapi server failure: %s", err)
}
}