Comments (3)
Here is my take, this also addresses the issue in config.go where non-defaults aren't applied if you don't give it a config file:
diff --git a/config/config.go b/config/config.go
index d7597ec..bc2d377 100644
--- a/config/config.go
+++ b/config/config.go
@@ -50,16 +50,21 @@ func (config *Config) BindFlags() processFlags {
db_params := flag.String("dbparams", Defaults.DBParams, "parameters to open the database (see Gorm's doc)")
return func() error {
- err := config.HandleConfFileFlag(*conf_file)
- if err != nil {
- return err
- }
+
// You can override fields in the config file with flags.
config.Host = *host
config.Port = *port
config.DBParams = *db_params
- err = config.SetDBType(*db_type)
- return err
+ err := config.SetDBType(*db_type)
+ if err != nil {
+ return err
+ }
+ err = config.HandleConfFileFlag(*conf_file)
+ if err != nil {
+ return err
+ }
+
+ return nil
}
}
diff --git a/db/gorm.go b/db/gorm.go
index 42ba2bf..693352e 100644
--- a/db/gorm.go
+++ b/db/gorm.go
@@ -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")
diff --git a/main.go b/main.go
index 7b91acf..88ba666 100755
--- a/main.go
+++ b/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"
@@ -39,7 +40,8 @@ func main() {
stdout.Flush()
os.Exit(0)
} else {
- conf_bind()
+ _ = conf_bind()
+ db.ORM, _ = db.GormInit(conf)
RunServer(conf)
}
}
from nyaa.
None of the parameters are working. Gonna fix it in a few minutes.
from nyaa.
Should be working in 86049d8
from nyaa.
Related Issues (20)
- 500 Internal Server Error when search yields no results. HOT 1
- status.panstu.cat 502 Bad Gateway error and general site slow down
- Missing File"https://a.doko.moe/sewang.mp3 " 404 not found
- Dates messed up again :( HOT 1
- torznab returns http400 on Gintama episode >54
- Upload time HOT 1
- 500 internal service error + postgresql queries are broken
- User Authentication Required?
- User not created when registering a new user. HOT 1
- translate error HOT 1
- RSS feed description tag should include link to torrent page
- Error with updating torrent using API
- Mascot audio files are unavailable
- translation id same HOT 1
- Refined Search: Using between sizes for File Sizes returns no results. HOT 1
- [Question] How to test upload API
- Search with hash in lowercase letters doesn't work
- Your adds have clickbait / fishing / virus in Brazil and you could get a black hat from google because of it.
- "No results found" HOT 1
- H
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nyaa.