51 lines
904 B
Go
51 lines
904 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"flag"
|
||
|
"log"
|
||
|
"runtime"
|
||
|
)
|
||
|
|
||
|
const (
|
||
|
appName = "rngpotd"
|
||
|
appVersion = "0.0.1"
|
||
|
userAgent = appName + "/" + appVersion
|
||
|
serverAgent = "nginx/1.27.0"
|
||
|
|
||
|
minimumGoMaxProcs = 2
|
||
|
maximumGoMaxProcs = 4
|
||
|
)
|
||
|
|
||
|
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)
|
||
|
}
|
||
|
if gmp > maximumGoMaxProcs {
|
||
|
runtime.GOMAXPROCS(maximumGoMaxProcs)
|
||
|
}
|
||
|
|
||
|
n_rngRetCodes = len(rngRetCodes)
|
||
|
|
||
|
log.SetFlags(log.Flags() | log.Lmicroseconds)
|
||
|
flag.Parse()
|
||
|
|
||
|
log.Printf("%s: starting\n", userAgent)
|
||
|
|
||
|
app := initFiberApp()
|
||
|
|
||
|
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)
|
||
|
}
|
||
|
}
|