-
Notifications
You must be signed in to change notification settings - Fork 12
/
main.go
53 lines (42 loc) · 1.02 KB
/
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
48
49
50
51
52
53
package main
import (
"os"
"os/signal"
"syscall"
"github.com/goravel/framework/facades"
"goravel/bootstrap"
)
func main() {
// This bootstraps the framework and gets it ready for use.
bootstrap.Boot()
// Create a channel to listen for OS signals
quit := make(chan os.Signal, 1)
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
// Start http server by facades.Route().
go func() {
if err := facades.Route().Run(); err != nil {
facades.Log().Errorf("Route run error: %v", err)
}
}()
// Start grpc server by facades.Grpc().
go func() {
if err := facades.Grpc().Run(); err != nil {
facades.Log().Errorf("Grpc run error: %v", err)
}
}()
// Start queue server by facades.Queue().
go func() {
if err := facades.Queue().Worker().Run(); err != nil {
facades.Log().Errorf("Queue run error: %v", err)
}
}()
// Listen for the OS signal
go func() {
<-quit
if err := facades.Route().Shutdown(); err != nil {
facades.Log().Errorf("Route Shutdown error: %v", err)
}
os.Exit(0)
}()
select {}
}