1
0
rngpotd/main.go
Konstantin Demin 35ce1ca21b
All checks were successful
ci/woodpecker/push/build Pipeline was successful
bump version
2024-10-04 08:01:09 +03:00

51 lines
937 B
Go

package main
import (
"flag"
"log"
"runtime"
)
const (
appName = "rngpotd"
appVersion = "0.0.3"
userAgent = appName + "/" + appVersion
serverAgent = "nginx/1.27.2"
minimumGoMaxProcs = 4
maximumGoMaxProcs = 8
)
var (
listenEndpoint string
)
func init() {
flag.StringVar(&listenEndpoint, "listen", ":8888", "listen (\":port\", \"address:port\")")
}
func main() {
gmp := runtime.GOMAXPROCS(0)
if gmp < minimumGoMaxProcs {
runtime.GOMAXPROCS(minimumGoMaxProcs)
} else if gmp > maximumGoMaxProcs {
runtime.GOMAXPROCS(maximumGoMaxProcs)
}
log.SetFlags(log.Flags() | log.Lmicroseconds)
flag.Parse()
log.Printf("%s: starting\n", userAgent)
app := initFiberApp()
if app == nil {
log.Fatal("failed to initialize rngpotd")
}
log.Printf("%s: ready\n", userAgent)
log.Printf("%s: going to listen %q\n", userAgent, listenEndpoint)
if err := app.Listen(listenEndpoint); err != nil {
log.Fatal(err)
}
}