-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
44 lines (35 loc) · 755 Bytes
/
main.go
File metadata and controls
44 lines (35 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Entry point for the server
package main
import (
"flag"
"fmt"
"net"
peacock "github.com/dropdevrahul/peacock/internal"
)
func main() {
host := flag.String("host", "0.0.0.0", "Host to listen on")
port := flag.String("port", "9999", "port to listen on")
size := flag.Uint64("max-size", 100000,
"Maximum number of items allowed in cache before LRU kicks in")
flag.Parse()
l, err := net.Listen("tcp4", *host+":"+*port)
if err != nil {
fmt.Println(err)
return
}
defer l.Close()
server := peacock.NewServer(
peacock.ServerSettings{
MaxCapacity: *size,
},
)
fmt.Printf("Server listening on %s:%s\n", *host, *port)
for {
c, err := l.Accept()
if err != nil {
fmt.Println(err)
return
}
go server.Serve(c)
}
}