-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
64 lines (52 loc) · 1.59 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
52
53
54
55
56
57
58
59
60
61
62
63
64
package main
import (
"flag"
"github.com/gin-gonic/gin"
"github.com/helloworldpark/tickle-stock-watcher/controller"
"github.com/helloworldpark/tickle-stock-watcher/storage"
"github.com/helloworldpark/tickle-stock-watcher/database"
"github.com/helloworldpark/tickle-stock-watcher/logger"
"github.com/helloworldpark/tickle-stock-watcher/push"
"github.com/helloworldpark/tickle-stock-watcher/structs"
)
func main() {
defer logger.Close()
credPath := flag.String("credential", "", "Credential for DB access")
telegramPath := flag.String("telegram", "", "Telegram token for webhook")
flag.Parse()
if credPath == nil || *credPath == "" {
logger.Panic("No -credential provided")
}
if telegramPath == nil || *telegramPath == "" {
logger.Panic("No -telegram provided")
}
// DB Client 생성
credential := database.LoadCredential(*credPath)
client := database.CreateClient()
client.Init(credential)
client.Open()
defer client.Close()
// DB 테이블 초기화
client.RegisterStructFromRegisterables([]database.DBRegisterable{
structs.Stock{},
structs.StockPrice{},
structs.User{},
structs.UserStock{},
structs.WatchingStock{},
structs.Invitation{},
})
// TelegramClient 초기화
push.InitTelegram(*telegramPath)
// Google Cloud Storage 초기화
storage.InitStorage()
// General 생성
general := controller.NewGeneral(client)
general.Initialize()
gin.SetMode(gin.ReleaseMode)
router := gin.Default()
router.GET("/", func(c *gin.Context) {
c.String(200, "Hello World!")
})
router.POST(push.URLTelegramUpdate(), push.OnTelegramUpdate(general))
router.Run("127.0.0.1:5003")
}