-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
51 lines (42 loc) · 1.07 KB
/
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
51
package main
import (
"fmt"
"net/http"
"os"
"time"
"github.com/gorilla/mux"
log "github.com/sirupsen/logrus"
"github.com/yowenter/buffet/pkg/server"
"github.com/yowenter/buffet/pkg/spider"
)
func init() {
log.SetOutput(os.Stdout)
log.SetLevel(log.DebugLevel)
}
func main() {
fmt.Println("IFTTT Service Buffet Starting ....")
iftttServiceKey := os.Getenv("IFTTT_SERVICE_KEY")
iftttChannelKey := os.Getenv("IFTTT_CHANNEL_KEY")
iftttConf := &server.IftttConf{
IftttChannelKey: iftttChannelKey,
IftttServiceKey: iftttServiceKey,
}
router := mux.NewRouter()
spider := spider.NewSpider("Ifttt")
buffetServer := &server.BuffetAPIServer{
Router: router,
Spider: spider,
IftttConf: iftttConf,
}
log.Debugf("Init Buffet server: `%+v` ", *buffetServer)
buffetServer.InstallHandlers()
buffetAPIServer := &http.Server{
Addr: ":5000",
Handler: buffetServer,
ReadTimeout: 30 * time.Second,
WriteTimeout: 30 * time.Second,
MaxHeaderBytes: 1 << 20,
}
go buffetServer.Spider.Run()
log.Fatal(buffetAPIServer.ListenAndServe())
}