-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
40 lines (34 loc) · 826 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
package main
import (
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/mysql"
"github.com/pkg/errors"
"github.com/airking05/go-exchange-chart-fetcher/config"
"github.com/airking05/go-exchange-chart-fetcher/models"
"github.com/airking05/go-exchange-chart-fetcher/server"
"fmt"
"os"
)
func help_and_exit() {
fmt.Fprintf(os.Stderr, "%s config.yml\n", os.Args[0])
os.Exit(1)
}
var ExchangeIDs = []models.ExchangeID{
models.Bitflyer,
models.Poloniex,
models.Hitbtc,
}
func main() {
if len(os.Args) != 2 {
help_and_exit()
}
confPath := os.Args[1]
conf := config.ReadConfig(confPath)
db, err := gorm.Open("mysql", conf.DBConnection)
if err != nil {
panic(errors.Wrap(err, "failed to connect db"))
}
db.AutoMigrate(&models.Chart{})
server := server.NewServer(ExchangeIDs, db)
server.Run()
}