kawipiko/sources/cmd/server-dummy.go

77 lines
1.3 KiB
Go
Raw Normal View History

package main
import "runtime"
import "runtime/debug"
import "time"
import "github.com/valyala/fasthttp"
import "github.com/valyala/fasthttp/reuseport"
func main () () {
runtime.GOMAXPROCS (2)
debug.SetGCPercent (50)
debug.SetMaxThreads (128)
debug.SetMaxStack (16 * 1024)
_listener, _error := reuseport.Listen ("tcp4", "127.9.185.194:8080")
if _error != nil { panic (_error) }
_server := & fasthttp.Server {
Name : "kawipiko",
Handler : serve,
GetOnly : true,
NoDefaultServerHeader : true,
NoDefaultContentType : true,
DisableHeaderNamesNormalizing : true,
Concurrency : 4 * 1024 + 128,
MaxRequestsPerConn : 256 * 1024,
ReadBufferSize : 16 * 1024,
WriteBufferSize : 16 * 1024,
MaxRequestBodySize : 16 * 1024,
// ReadTimeout : 30 * time.Second,
// WriteTimeout : 30 * time.Second,
// IdleTimeout : 360 * time.Second,
TCPKeepalive : true,
TCPKeepalivePeriod : 60 * time.Second,
ReduceMemoryUsage : false,
KeepHijackedConns : true,
ErrorHandler : nil,
ConnState : nil,
HeaderReceived : nil,
Logger : nil,
LogAllErrors : true,
}
_error = _server.Serve (_listener)
if _error != nil { panic (_error) }
}
func serve (_context *fasthttp.RequestCtx) () {
_context.Response.SetBodyRaw (serveData)
}
var serveData = []byte ("hello world!\n")