1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-22 14:49:42 +02:00
This commit is contained in:
Harvey Kandola 2017-07-20 18:46:11 +01:00
parent 56238b00c5
commit 6fd6bc6d26
7 changed files with 663 additions and 663 deletions

View file

@ -8,7 +8,7 @@ The mission is to bring software dev inspired features (refactoring, testing, li
## Latest version ## Latest version
v1.50.0 v1.50.1
## OS Support ## OS Support

View file

@ -36,7 +36,7 @@ var dbPtr *sqlx.DB
// Check that the database is configured correctly and that all the required tables exist. // Check that the database is configured correctly and that all the required tables exist.
// It must be the first function called in this package. // It must be the first function called in this package.
func Check(runtime env.Runtime) bool { func Check(runtime *env.Runtime) bool {
dbPtr = runtime.Db dbPtr = runtime.Db
log.Info("Database checks: started") log.Info("Database checks: started")

View file

@ -26,36 +26,6 @@ import (
// InitRuntime prepares runtime using command line and environment variables. // InitRuntime prepares runtime using command line and environment variables.
func InitRuntime(r *env.Runtime) bool { func InitRuntime(r *env.Runtime) bool {
// Prepare DB
db, err := sqlx.Open("mysql", stdConn(r.Flags.DBConn))
if err != nil {
r.Log.Error("unable to setup database", err)
}
r.Db = db
r.Db.SetMaxIdleConns(30)
r.Db.SetMaxOpenConns(100)
r.Db.SetConnMaxLifetime(time.Second * 14400)
err = r.Db.Ping()
if err != nil {
r.Log.Error("unable to connect to database, connection string should be of the form: '"+
"username:password@tcp(host:3306)/database'", err)
return false
}
// go into setup mode if required
if r.Flags.SiteMode != web.SiteModeOffline {
if database.Check(*r) {
if err := database.Migrate(true /* the config table exists */); err != nil {
r.Log.Error("unable to run database migration", err)
return false
}
} else {
r.Log.Info("going into setup mode to prepare new database")
}
}
// Prepare SALT // Prepare SALT
if r.Flags.Salt == "" { if r.Flags.Salt == "" {
b := make([]byte, 17) b := make([]byte, 17)
@ -90,6 +60,36 @@ func InitRuntime(r *env.Runtime) bool {
} }
} }
// Prepare DB
db, err := sqlx.Open("mysql", stdConn(r.Flags.DBConn))
if err != nil {
r.Log.Error("unable to setup database", err)
}
r.Db = db
r.Db.SetMaxIdleConns(30)
r.Db.SetMaxOpenConns(100)
r.Db.SetConnMaxLifetime(time.Second * 14400)
err = r.Db.Ping()
if err != nil {
r.Log.Error("unable to connect to database, connection string should be of the form: '"+
"username:password@tcp(host:3306)/database'", err)
return false
}
// go into setup mode if required
if r.Flags.SiteMode != web.SiteModeOffline {
if database.Check(r) {
if err := database.Migrate(true /* the config table exists */); err != nil {
r.Log.Error("unable to run database migration", err)
return false
}
} else {
r.Log.Info("going into setup mode to prepare new database")
}
}
return true return true
} }

View file

@ -37,7 +37,7 @@ func init() {
runtime.Product = env.ProdInfo{} runtime.Product = env.ProdInfo{}
runtime.Product.Major = "1" runtime.Product.Major = "1"
runtime.Product.Minor = "50" runtime.Product.Minor = "50"
runtime.Product.Patch = "0" runtime.Product.Patch = "1"
runtime.Product.Version = fmt.Sprintf("%s.%s.%s", runtime.Product.Major, runtime.Product.Minor, runtime.Product.Patch) runtime.Product.Version = fmt.Sprintf("%s.%s.%s", runtime.Product.Major, runtime.Product.Minor, runtime.Product.Patch)
runtime.Product.Edition = "Community" runtime.Product.Edition = "Community"
runtime.Product.Title = fmt.Sprintf("%s Edition", runtime.Product.Edition) runtime.Product.Title = fmt.Sprintf("%s Edition", runtime.Product.Edition)

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{ {
"name": "documize", "name": "documize",
"version": "1.50.0", "version": "1.50.1",
"description": "The Document IDE", "description": "The Document IDE",
"private": true, "private": true,
"repository": "", "repository": "",

View file

@ -1,16 +1,16 @@
{ {
"community": "community":
{ {
"version": "1.50.0", "version": "1.50.1",
"major": 1, "major": 1,
"minor": 50, "minor": 50,
"patch": 0 "patch": 1
}, },
"enterprise": "enterprise":
{ {
"version": "1.52.0", "version": "1.52.1",
"major": 1, "major": 1,
"minor": 52, "minor": 52,
"patch": 0 "patch": 1
} }
} }