-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.go
47 lines (37 loc) · 924 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"
"math/rand"
"net/http"
"os"
"os/signal"
"syscall"
"time"
)
var server *http.Server
var stop chan os.Signal
var MicrosoftTeamWebhook string
func init() {
stop = make(chan os.Signal, 1)
signal.Notify(stop, os.Interrupt, syscall.SIGTERM)
MicrosoftTeamWebhook = os.Getenv("MICROSOFT_TEAM_WEBHOOK")
fmt.Println(fmt.Sprintf("Using Microsoft Team Webhook URL: %s", MicrosoftTeamWebhook))
}
func main() {
fmt.Println("Starting up ...")
rand.Seed(time.Now().UnixNano())
server = GetWebServer()
go func() {
fmt.Println("Starting xray ms team integration server...")
if err := server.ListenAndServe(); err != nil {
fmt.Println(fmt.Sprintf("Http server stopped: %s", err))
stop <- os.Interrupt
}
}()
<-stop
fmt.Println("Stop signal received!")
fmt.Println("Shutting down server...")
server.Shutdown(context.Background())
fmt.Println("Server stopped!")
}