2019-08-12 11:01:15 +00:00
|
|
|
|
|
|
|
package main
|
|
|
|
|
2019-08-12 12:34:08 +00:00
|
|
|
|
2019-08-12 11:01:15 +00:00
|
|
|
import "runtime"
|
|
|
|
import "runtime/debug"
|
2019-08-12 12:34:08 +00:00
|
|
|
import "time"
|
|
|
|
|
2019-08-12 11:01:15 +00:00
|
|
|
import "github.com/valyala/fasthttp"
|
|
|
|
import "github.com/valyala/fasthttp/reuseport"
|
|
|
|
|
|
|
|
|
2019-08-12 12:34:08 +00:00
|
|
|
|
|
|
|
|
2019-08-12 11:01:15 +00:00
|
|
|
func main () () {
|
|
|
|
|
2019-08-12 12:34:08 +00:00
|
|
|
|
2019-08-12 11:01:15 +00:00
|
|
|
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) }
|
|
|
|
|
2019-08-12 12:34:08 +00:00
|
|
|
_server := & fasthttp.Server {
|
|
|
|
|
|
|
|
Name : "kawipiko",
|
|
|
|
Handler : serve,
|
|
|
|
GetOnly : true,
|
|
|
|
|
|
|
|
NoDefaultServerHeader : true,
|
|
|
|
NoDefaultContentType : true,
|
2019-08-12 17:43:30 +00:00
|
|
|
NoDefaultDate : true,
|
2019-08-12 12:34:08 +00:00
|
|
|
DisableHeaderNamesNormalizing : true,
|
|
|
|
|
|
|
|
Concurrency : 4 * 1024 + 128,
|
|
|
|
MaxRequestsPerConn : 256 * 1024,
|
|
|
|
|
|
|
|
ReadBufferSize : 16 * 1024,
|
|
|
|
WriteBufferSize : 16 * 1024,
|
|
|
|
MaxRequestBodySize : 16 * 1024,
|
|
|
|
|
2019-08-12 17:43:30 +00:00
|
|
|
// ReadTimeout : 30 * time.Second,
|
|
|
|
// WriteTimeout : 30 * time.Second,
|
|
|
|
// IdleTimeout : 360 * time.Second,
|
2019-08-12 12:34:08 +00:00
|
|
|
|
|
|
|
TCPKeepalive : true,
|
|
|
|
TCPKeepalivePeriod : 60 * time.Second,
|
|
|
|
|
|
|
|
ReduceMemoryUsage : false,
|
|
|
|
KeepHijackedConns : true,
|
|
|
|
|
|
|
|
ErrorHandler : nil,
|
|
|
|
ConnState : nil,
|
|
|
|
HeaderReceived : nil,
|
|
|
|
|
|
|
|
Logger : nil,
|
|
|
|
LogAllErrors : true,
|
|
|
|
|
|
|
|
}
|
2019-08-12 11:01:15 +00:00
|
|
|
|
2019-08-12 12:34:08 +00:00
|
|
|
_error = _server.Serve (_listener)
|
2019-08-12 11:01:15 +00:00
|
|
|
if _error != nil { panic (_error) }
|
|
|
|
}
|
|
|
|
|
2019-08-12 12:34:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func serve (_context *fasthttp.RequestCtx) () {
|
|
|
|
_context.Response.SetBodyRaw (serveData)
|
|
|
|
}
|
|
|
|
|
|
|
|
var serveData = []byte ("hello world!\n")
|
|
|
|
|