ripple-api/main.go

61 lines
1.1 KiB
Go
Raw Normal View History

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"
"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"
"github.com/jmoiron/sqlx"
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
}
var db *sqlx.DB
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 = "&"
}
conf.DSN += c + "parseTime=true"
}
var err error
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-04-07 17:32:48 +00:00
engine := app.Start(conf, db)
startuato(engine)
2016-04-03 17:59:27 +00:00
}