diff --git a/sources/cmd/server-dummy.go b/sources/cmd/server-dummy.go index 5639201..24debdf 100644 --- a/sources/cmd/server-dummy.go +++ b/sources/cmd/server-dummy.go @@ -2,6 +2,8 @@ package main +import "fmt" +import "os" import "runtime" import "runtime/debug" import "time" @@ -22,8 +24,24 @@ func main () () { debug.SetMaxStack (16 * 1024) - _listener, _error := reuseport.Listen ("tcp4", "127.9.185.194:8080") - if _error != nil { panic (_error) } + _endpoint := "127.0.0.1:8080" + _timeouts := false + + switch len (os.Args) { + case 1 : + // NOP + case 2 : + _endpoint = os.Args[1] + default : + panic ("[60023f00] invalid arguments!") + } + + _listener, _error := reuseport.Listen ("tcp4", _endpoint) + if _error != nil { + panic (fmt.Sprintf ("[8c30a625] failed to listen: %s", _error)) + } + + fmt.Fprintf (os.Stderr, "[ii] listening on `http://%s/`...\n", _endpoint) _server := & fasthttp.Server { @@ -43,15 +61,17 @@ func main () () { WriteBufferSize : 16 * 1024, MaxRequestBodySize : 16 * 1024, - // ReadTimeout : 30 * time.Second, - // WriteTimeout : 30 * time.Second, - // IdleTimeout : 360 * time.Second, + ReadTimeout : 30 * time.Second, + WriteTimeout : 30 * time.Second, + IdleTimeout : 360 * time.Second, TCPKeepalive : true, TCPKeepalivePeriod : 60 * time.Second, ReduceMemoryUsage : false, - KeepHijackedConns : true, + + CloseOnShutdown : true, + DisableKeepalive : false, ErrorHandler : nil, ConnState : nil, @@ -62,18 +82,24 @@ func main () () { } + if !_timeouts { + _server.ReadTimeout = 0 + _server.WriteTimeout = 0 + _server.IdleTimeout = 0 + } + _error = _server.Serve (_listener) - if _error != nil { panic (_error) } + if _error != nil { + panic (fmt.Sprintf ("[ee9bc0a5] failed to serve: %s", _error)) + } } func serve (_context *fasthttp.RequestCtx) () { - _context.Response.Header.SetRaw (serveMeta) _context.Response.SetBodyRaw (serveData) } -var serveMeta = []byte ("HTTP/1.1 200 OK\r\nContent-Length: 13\r\n\r\n") var serveData = []byte ("hello world!\n") diff --git a/sources/cmd/server/server.go b/sources/cmd/server/server.go index c5d22dd..a447236 100644 --- a/sources/cmd/server/server.go +++ b/sources/cmd/server/server.go @@ -1181,6 +1181,9 @@ func main_0 () (error) { ReduceMemoryUsage : _httpServerReduceMemory, + CloseOnShutdown : true, + DisableKeepalive : false, + } _httpsServer := & fasthttp.Server {}