-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (32 loc) · 776 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
package main
import (
"os"
"os/signal"
"syscall"
"github.com/goravel/framework/facades"
"chat/bootstrap"
)
func main() {
// This bootstraps the framework and gets it ready for use.
bootstrap.Boot()
// Start schedule by facades.Schedule().
go facades.Schedule().Run()
// Create a channel to listen for OS signals
quit := make(chan os.Signal)
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)
}
}()
// 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 {}
}