forked from vkuznet/MLHub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
57 lines (48 loc) · 1.28 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
package main
// mlaas-proxy - Go implementation of reverse proxy server for MLaaS backends
//
// Copyright (c) 2023 - Valentin Kuznetsov <[email protected]>
//
import (
"flag"
"fmt"
"log"
"os"
"runtime"
"time"
_ "expvar" // to be used for monitoring, see https://github.com/divan/expvarmon
_ "net/http/pprof" // profiler, see https://golang.org/pkg/net/http/pprof/
)
// version of the code
var version string
// helper function to return version string of the server
func info() string {
goVersion := runtime.Version()
tstamp := time.Now().Format("2006-02-01")
return fmt.Sprintf("auth-proxy-server git=%s go=%s date=%s", version, goVersion, tstamp)
}
func main() {
var config string
flag.StringVar(&config, "config", "", "configuration file")
var version bool
flag.BoolVar(&version, "version", false, "print version information about the server")
flag.Parse()
if version {
fmt.Println(info())
os.Exit(0)
}
err := parseConfig(config)
if err != nil {
log.Fatalf("unable to parse config %s, error %v\n", config, err)
}
// configure logger with log time, filename, and line number
log.SetFlags(0)
if Config.Verbose > 0 {
log.SetFlags(log.LstdFlags | log.Lshortfile)
}
if Config.Verbose > 0 {
log.Printf("%+v\n", Config)
}
// start proxy server
Server()
}