forked from orderbynull/lottip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (33 loc) · 1.12 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
package main
import (
"flag"
"fmt"
"time"
"github.com/orderbynull/lottip/chat"
)
var (
proxyAddr = flag.String("proxy", "127.0.0.1:4041", "Proxy <host>:<port>")
mysqlAddr = flag.String("mysql", "127.0.0.1:3306", "MySQL <host>:<port>")
guiAddr = flag.String("gui", "127.0.0.1:9999", "Web UI <host>:<port>")
useLocalUI = flag.Bool("use-local", false, "Use local UI instead of embed")
mysqlDsn = flag.String("mysql-dsn", "", "MySQL DSN for query execution capabilities")
)
func appReadyInfo(appReadyChan chan bool) {
<-appReadyChan
time.Sleep(1 * time.Second)
fmt.Printf("Forwarding queries from `%s` to `%s` \n", *proxyAddr, *mysqlAddr)
fmt.Printf("Web gui available at `http://%s` \n", *guiAddr)
}
func main() {
flag.Parse()
cmdChan := make(chan chat.Cmd)
cmdResultChan := make(chan chat.CmdResult)
connStateChan := make(chan chat.ConnState)
appReadyChan := make(chan bool)
hub := chat.NewHub(cmdChan, cmdResultChan, connStateChan)
go hub.Run()
go runHttpServer(hub)
go appReadyInfo(appReadyChan)
p := MySQLProxyServer{cmdChan, cmdResultChan, connStateChan, appReadyChan, *mysqlAddr, *proxyAddr}
p.run()
}