2016-04-03 17:59:27 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2016-04-07 17:32:48 +00:00
|
|
|
"fmt"
|
2016-04-03 17:59:27 +00:00
|
|
|
"log"
|
2016-07-06 22:20:36 +00:00
|
|
|
"strings"
|
2016-04-07 17:32:48 +00:00
|
|
|
"syscall"
|
2016-04-03 17:59:27 +00:00
|
|
|
|
2016-04-19 14:07:27 +00:00
|
|
|
"git.zxq.co/ripple/rippleapi/app"
|
2016-09-06 23:51:23 +00:00
|
|
|
"git.zxq.co/ripple/rippleapi/beatmapget"
|
2016-04-19 14:07:27 +00:00
|
|
|
"git.zxq.co/ripple/rippleapi/common"
|
2016-05-22 15:11:07 +00:00
|
|
|
"git.zxq.co/ripple/schiavolib"
|
2016-04-03 17:59:27 +00:00
|
|
|
// Golint pls dont break balls
|
|
|
|
_ "github.com/go-sql-driver/mysql"
|
2016-08-15 11:37:03 +00:00
|
|
|
"github.com/jmoiron/sqlx"
|
2016-09-06 23:51:23 +00:00
|
|
|
"gopkg.in/thehowl/go-osuapi.v1"
|
2016-04-03 17:59:27 +00:00
|
|
|
)
|
|
|
|
|
2016-06-17 08:34:53 +00:00
|
|
|
// Version is the git hash of the application. Do not edit. This is
|
|
|
|
// automatically set using -ldflags during build time.
|
|
|
|
var Version string
|
|
|
|
|
2016-04-07 17:32:48 +00:00
|
|
|
func init() {
|
|
|
|
log.SetFlags(log.Ltime)
|
|
|
|
log.SetPrefix(fmt.Sprintf("%d|", syscall.Getpid()))
|
2016-06-17 08:34:53 +00:00
|
|
|
common.Version = Version
|
2016-04-07 17:32:48 +00:00
|
|
|
}
|
|
|
|
|
2016-08-15 11:37:03 +00:00
|
|
|
var db *sqlx.DB
|
2016-06-22 11:13:33 +00:00
|
|
|
|
2016-04-03 17:59:27 +00:00
|
|
|
func main() {
|
2016-06-17 08:34:53 +00:00
|
|
|
fmt.Print("Ripple API")
|
|
|
|
if Version != "" {
|
|
|
|
fmt.Print("; git commit hash: ", Version)
|
|
|
|
}
|
|
|
|
fmt.Println()
|
|
|
|
|
2016-04-03 17:59:27 +00:00
|
|
|
conf, halt := common.Load()
|
|
|
|
if halt {
|
|
|
|
return
|
|
|
|
}
|
2016-05-22 15:11:07 +00:00
|
|
|
|
|
|
|
schiavo.Prefix = "Ripple API"
|
|
|
|
|
2016-07-06 22:20:36 +00:00
|
|
|
if !strings.Contains(conf.DSN, "parseTime=true") {
|
|
|
|
c := "?"
|
|
|
|
if strings.Contains(conf.DSN, "?") {
|
|
|
|
c = "&"
|
|
|
|
}
|
2016-11-20 12:46:44 +00:00
|
|
|
conf.DSN += c + "parseTime=true&charset=utf8mb4,utf8&collation=utf8mb4_general_ci"
|
2016-07-06 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2016-06-22 11:13:33 +00:00
|
|
|
var err error
|
2016-08-15 11:37:03 +00:00
|
|
|
db, err = sqlx.Open(conf.DatabaseType, conf.DSN)
|
2016-04-03 17:59:27 +00:00
|
|
|
if err != nil {
|
2016-05-22 15:11:07 +00:00
|
|
|
schiavo.Bunker.Send(err.Error())
|
|
|
|
log.Fatalln(err)
|
2016-04-03 17:59:27 +00:00
|
|
|
}
|
2016-09-06 23:51:23 +00:00
|
|
|
|
|
|
|
beatmapget.Client = osuapi.NewClient(conf.OsuAPIKey)
|
|
|
|
beatmapget.DB = db
|
|
|
|
|
2016-04-07 17:32:48 +00:00
|
|
|
engine := app.Start(conf, db)
|
|
|
|
|
2016-06-22 11:13:33 +00:00
|
|
|
startuato(engine)
|
2016-04-03 17:59:27 +00:00
|
|
|
}
|