fixed for good now
Cette révision appartient à :
Parent
f7127ab3be
révision
5c4d1da8b7
3 fichiers modifiés avec 10 ajouts et 10 suppressions
|
@ -2,18 +2,17 @@ package db
|
|||
|
||||
import (
|
||||
"github.com/ewhal/nyaa/config"
|
||||
"github.com/ewhal/nyaa/util/log"
|
||||
"github.com/ewhal/nyaa/model"
|
||||
"github.com/ewhal/nyaa/util/log"
|
||||
"github.com/jinzhu/gorm"
|
||||
_ "github.com/jinzhu/gorm/dialects/sqlite"
|
||||
// _ "github.com/go-sql-driver/mysql"
|
||||
)
|
||||
|
||||
var ORM, Errs = GormInit()
|
||||
var ORM *gorm.DB
|
||||
|
||||
// GormInit init gorm ORM.
|
||||
func GormInit() (*gorm.DB, error) {
|
||||
conf := config.NewConfig()
|
||||
func GormInit(conf *config.Config) (*gorm.DB, error) {
|
||||
db, err := gorm.Open(conf.DBType, conf.DBParams)
|
||||
// db, err := gorm.Open("mysql", config.MysqlDSL())
|
||||
//db, err := gorm.Open("sqlite3", "/tmp/gorm.db")
|
||||
|
|
BIN
dbdb
Fichier normal
BIN
dbdb
Fichier normal
Fichier binaire non affiché.
13
main.go
13
main.go
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/ewhal/nyaa/config"
|
||||
"github.com/ewhal/nyaa/db"
|
||||
"github.com/ewhal/nyaa/router"
|
||||
"github.com/ewhal/nyaa/util/log"
|
||||
|
||||
|
@ -30,20 +31,20 @@ func RunServer(conf *config.Config) {
|
|||
|
||||
func main() {
|
||||
conf := config.NewConfig()
|
||||
conf_bind := conf.BindFlags()
|
||||
process_flags := conf.BindFlags()
|
||||
defaults := flag.Bool("print-defaults", false, "print the default configuration file on stdout")
|
||||
flag.Parse()
|
||||
err := conf_bind()
|
||||
if err != nil {
|
||||
log.CheckError(err)
|
||||
}
|
||||
if *defaults {
|
||||
stdout := bufio.NewWriter(os.Stdout)
|
||||
conf.Pretty(stdout)
|
||||
stdout.Flush()
|
||||
os.Exit(0)
|
||||
} else {
|
||||
conf_bind()
|
||||
err := process_flags()
|
||||
if err != nil {
|
||||
log.CheckError(err)
|
||||
}
|
||||
db.ORM, _ = db.GormInit(conf)
|
||||
RunServer(conf)
|
||||
}
|
||||
}
|
||||
|
|
Référencer dans un nouveau ticket