-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.go
50 lines (44 loc) · 927 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
48
49
50
package main
import (
"fmt"
"github.com/opengovern/og-task-template/worker"
"golang.org/x/net/context"
"os"
"os/signal"
"syscall"
)
var (
// Stream name
StreamName = os.Getenv("STREAM_NAME")
// Queue name
QueueName = os.Getenv("QUEUE_NAME")
// Topic name Reciever
TopicNameReciever = os.Getenv("TOPIC_NAME")
// Nats server url
NatsURL = os.Getenv("NATS_URL")
// Topic name Sender
TopicNameSender = os.Getenv("TOPIC_NAME_SENDER")
// GRPC server url
GRPCServerURL = os.Getenv("GRPC_SERVER_URL")
)
func main() {
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
defer func() {
signal.Stop(c)
cancel()
}()
go func() {
select {
case <-c:
cancel()
case <-ctx.Done():
}
}()
if err := worker.WorkerCommand().ExecuteContext(ctx); err != nil {
fmt.Printf("Error: %v\n", err)
os.Exit(1)
}
}