forked from ossn/fixme_backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
43 lines (36 loc) · 724 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
package main
import (
"context"
"log"
"os"
"os/signal"
"github.com/ossn/fixme_backend/actions"
"github.com/ossn/fixme_backend/worker"
)
// main is the starting point to your Buffalo application.
func main() {
ctx := context.Background()
// trap Ctrl+C and call cancel on the context
ctx, cancel := context.WithCancel(ctx)
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
defer func() {
signal.Stop(c)
cancel()
}()
// Go routine to listen for os messages
go func() {
select {
case <-c:
cancel()
case <-ctx.Done():
}
}()
// Start worker
go worker.WorkerInst.Init(ctx, c)
app := actions.App(ctx)
// Start app serve
if err := app.Serve(); err != nil {
log.Fatal(err)
}
}