-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmain.go
More file actions
40 lines (30 loc) · 755 Bytes
/
Copy pathmain.go
File metadata and controls
40 lines (30 loc) · 755 Bytes
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
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"github.com/duo/matrix-wechat-agent/internal/common"
"github.com/duo/matrix-wechat-agent/internal/wechat"
log "github.com/sirupsen/logrus"
)
func main() {
config, err := common.LoadConfig("configure.yaml")
if err != nil {
log.Fatal(err)
}
logLevel, err := log.ParseLevel(config.Log.Level)
if err == nil {
log.SetLevel(logLevel)
}
log.SetFormatter(&log.TextFormatter{TimestampFormat: "2006-01-02 15:04:05", FullTimestamp: true})
driver := wechat.LoadDriver()
defer syscall.FreeLibrary(driver)
service := wechat.NewService(config)
go service.Start()
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
<-c
fmt.Printf("\n")
service.Stop()
}