-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
47 lines (42 loc) · 988 Bytes
/
main.go
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
45
46
47
package main
import (
"context"
"fmt"
"net/http"
_ "net/http/pprof"
"os"
"runtime"
"runtime/debug"
"syscall"
"github.com/clubpay/ronykit/example/ex-02-rest/api"
"github.com/clubpay/ronykit/kit"
"github.com/clubpay/ronykit/std/gateways/fasthttp"
)
func main() {
runtime.GOMAXPROCS(4)
go func() {
_ = http.ListenAndServe(":1234", nil)
}()
// Create, start and wait for shutdown signal of the server.
defer kit.NewServer(
// kit.WithPrefork(),
kit.WithErrorHandler(func(ctx *kit.Context, err error) {
fmt.Println(err, string(debug.Stack()))
}),
kit.WithGateway(
fasthttp.MustNew(
fasthttp.Listen(":80"),
fasthttp.WithServerName("RonyKIT Server"),
fasthttp.WithCORS(fasthttp.CORSConfig{}),
fasthttp.WithWebsocketEndpoint("/ws"),
fasthttp.WithPredicateKey("cmd"),
),
),
kit.WithServiceDesc(
api.SampleDesc.Desc(),
),
).
Start(context.TODO()).
PrintRoutesCompact(os.Stdout).
Shutdown(context.TODO(), syscall.SIGHUP)
}