46 lines
803 B
Go
46 lines
803 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"log"
|
|
"runtime"
|
|
)
|
|
|
|
const (
|
|
appName = "vault-usage"
|
|
appVersion = "0.0.1"
|
|
userAgent = appName + "/" + appVersion
|
|
|
|
minimumGoMaxProcs = 4
|
|
)
|
|
|
|
var (
|
|
apiRootUri string
|
|
listenEndpoint string
|
|
)
|
|
|
|
func init() {
|
|
flag.StringVar(&apiRootUri, "api-root-uri", "/v1", "API root URI")
|
|
flag.StringVar(&listenEndpoint, "listen", ":3000", "listen (\":port\", \"address:port\")")
|
|
}
|
|
|
|
func main() {
|
|
gmp := runtime.GOMAXPROCS(0)
|
|
if gmp < minimumGoMaxProcs {
|
|
runtime.GOMAXPROCS(minimumGoMaxProcs)
|
|
}
|
|
|
|
log.SetFlags(log.Flags() | log.Lmicroseconds)
|
|
flag.Parse()
|
|
|
|
log.Printf("%s: starting\n", userAgent)
|
|
|
|
app := initFiber()
|
|
setupVaultApi(app.Group(apiRootUri))
|
|
|
|
log.Printf("%s: ready\n", userAgent)
|
|
if err := app.Listen(listenEndpoint); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|