mirror of
https://github.com/documize/community.git
synced 2025-07-21 14:19:43 +02:00
Add dbtype command line switch and improved database type detection
Closes #116 and #117
This commit is contained in:
parent
d3512b499a
commit
e505bb36e2
10 changed files with 659 additions and 644 deletions
|
@ -8,7 +8,7 @@ The mission is to bring software dev inspired features (refactoring, testing, li
|
||||||
|
|
||||||
## Latest version
|
## Latest version
|
||||||
|
|
||||||
v1.53.2
|
v1.53.3
|
||||||
|
|
||||||
## OS Support
|
## OS Support
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ func Check(runtime *env.Runtime) bool {
|
||||||
web.SiteInfo.DBname = strings.Split(csBits[len(csBits)-1], "?")[0]
|
web.SiteInfo.DBname = strings.Split(csBits[len(csBits)-1], "?")[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
rows, err := runtime.Db.Query("SELECT VERSION() AS version, @@version_comment as comment, @@character_set_database AS charset, @@collation_database AS collation;")
|
rows, err := runtime.Db.Query("SELECT VERSION() AS version, @@version_comment as comment, @@character_set_database AS charset, @@collation_database AS collation")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
runtime.Log.Error("Can't get MySQL configuration", err)
|
runtime.Log.Error("Can't get MySQL configuration", err)
|
||||||
web.SiteInfo.Issue = "Can't get MySQL configuration: " + err.Error()
|
web.SiteInfo.Issue = "Can't get MySQL configuration: " + err.Error()
|
||||||
|
@ -61,7 +61,7 @@ func Check(runtime *env.Runtime) bool {
|
||||||
// Get SQL variant as this affects minimum version checking logic.
|
// Get SQL variant as this affects minimum version checking logic.
|
||||||
// MySQL and Percona share same version scheme (e..g 5.7.10).
|
// MySQL and Percona share same version scheme (e..g 5.7.10).
|
||||||
// MariaDB starts at 10.2.x
|
// MariaDB starts at 10.2.x
|
||||||
runtime.DbVariant = GetSQLVariant(dbComment)
|
runtime.DbVariant = GetSQLVariant(runtime.Flags.DBType, dbComment)
|
||||||
runtime.Log.Info(fmt.Sprintf("Database checks: SQL variant %v", runtime.DbVariant))
|
runtime.Log.Info(fmt.Sprintf("Database checks: SQL variant %v", runtime.DbVariant))
|
||||||
runtime.Log.Info("Database checks: SQL version " + version)
|
runtime.Log.Info("Database checks: SQL version " + version)
|
||||||
|
|
||||||
|
@ -142,9 +142,11 @@ func Check(runtime *env.Runtime) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSQLVariant uses database value form @@version_comment to deduce MySQL variant.
|
// GetSQLVariant uses database value form @@version_comment to deduce MySQL variant.
|
||||||
func GetSQLVariant(vc string) env.DbVariant {
|
func GetSQLVariant(dbType, vc string) env.DbVariant {
|
||||||
vc = strings.ToLower(vc)
|
vc = strings.ToLower(vc)
|
||||||
|
dbType = strings.ToLower(dbType)
|
||||||
|
|
||||||
|
// determine type from database
|
||||||
if strings.Contains(vc, "mariadb") {
|
if strings.Contains(vc, "mariadb") {
|
||||||
return env.DBVariantMariaDB
|
return env.DBVariantMariaDB
|
||||||
} else if strings.Contains(vc, "percona") {
|
} else if strings.Contains(vc, "percona") {
|
||||||
|
@ -153,7 +155,17 @@ func GetSQLVariant(vc string) env.DbVariant {
|
||||||
return env.DbVariantMySQL
|
return env.DbVariantMySQL
|
||||||
}
|
}
|
||||||
|
|
||||||
return "UNKNOWN"
|
// now determine type from command line switch
|
||||||
|
if strings.Contains(dbType, "mariadb") {
|
||||||
|
return env.DBVariantMariaDB
|
||||||
|
} else if strings.Contains(dbType, "percona") {
|
||||||
|
return env.DBVariantPercona
|
||||||
|
} else if strings.Contains(dbType, "mysql") {
|
||||||
|
return env.DbVariantMySQL
|
||||||
|
}
|
||||||
|
|
||||||
|
// horrid default could cause app to crash
|
||||||
|
return env.DbVariantMySQL
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSQLVersion returns SQL version as major,minor,patch numerics.
|
// GetSQLVersion returns SQL version as major,minor,patch numerics.
|
||||||
|
|
|
@ -125,7 +125,7 @@ func lockDB(runtime *env.Runtime) (bool, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// good error would be "Error 1062: Duplicate entry 'DBLOCK' for key 'idx_config_area'"
|
// good error would be "Error 1062: Duplicate entry 'DBLOCK' for key 'idx_config_area'"
|
||||||
if strings.HasPrefix(err.Error(), "Error 1062:") {
|
if strings.HasPrefix(err.Error(), "Error 1062:") {
|
||||||
runtime.Log.Info("Database locked by annother Documize instance")
|
runtime.Log.Info("Database locked by another Documize instance")
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
return false, err
|
return false, err
|
||||||
|
|
5
core/env/flags.go
vendored
5
core/env/flags.go
vendored
|
@ -25,6 +25,7 @@ import (
|
||||||
type Flags struct {
|
type Flags struct {
|
||||||
DBConn string // database connection string
|
DBConn string // database connection string
|
||||||
Salt string // the salt string used to encode JWT tokens
|
Salt string // the salt string used to encode JWT tokens
|
||||||
|
DBType string // (optional) database type
|
||||||
SSLCertFile string // (optional) name of SSL certificate PEM file
|
SSLCertFile string // (optional) name of SSL certificate PEM file
|
||||||
SSLKeyFile string // (optional) name of SSL key PEM file
|
SSLKeyFile string // (optional) name of SSL key PEM file
|
||||||
HTTPPort string // (optional) HTTP or HTTPS port
|
HTTPPort string // (optional) HTTP or HTTPS port
|
||||||
|
@ -71,7 +72,7 @@ var loadMutex sync.Mutex
|
||||||
|
|
||||||
// ParseFlags loads command line and OS environment variables required by the program to function.
|
// ParseFlags loads command line and OS environment variables required by the program to function.
|
||||||
func ParseFlags() (f Flags) {
|
func ParseFlags() (f Flags) {
|
||||||
var dbConn, jwtKey, siteMode, port, certFile, keyFile, forcePort2SSL string
|
var dbConn, dbType, jwtKey, siteMode, port, certFile, keyFile, forcePort2SSL string
|
||||||
|
|
||||||
register(&jwtKey, "salt", false, "the salt string used to encode JWT tokens, if not set a random value will be generated")
|
register(&jwtKey, "salt", false, "the salt string used to encode JWT tokens, if not set a random value will be generated")
|
||||||
register(&certFile, "cert", false, "the cert.pem file used for https")
|
register(&certFile, "cert", false, "the cert.pem file used for https")
|
||||||
|
@ -79,6 +80,7 @@ func ParseFlags() (f Flags) {
|
||||||
register(&port, "port", false, "http/https port number")
|
register(&port, "port", false, "http/https port number")
|
||||||
register(&forcePort2SSL, "forcesslport", false, "redirect given http port number to TLS")
|
register(&forcePort2SSL, "forcesslport", false, "redirect given http port number to TLS")
|
||||||
register(&siteMode, "offline", false, "set to '1' for OFFLINE mode")
|
register(&siteMode, "offline", false, "set to '1' for OFFLINE mode")
|
||||||
|
register(&dbType, "dbtype", false, "set to database type mysql|percona|mariadb")
|
||||||
register(&dbConn, "db", true, `'username:password@protocol(hostname:port)/databasename" for example "fred:bloggs@tcp(localhost:3306)/documize"`)
|
register(&dbConn, "db", true, `'username:password@protocol(hostname:port)/databasename" for example "fred:bloggs@tcp(localhost:3306)/documize"`)
|
||||||
|
|
||||||
parse("db")
|
parse("db")
|
||||||
|
@ -90,6 +92,7 @@ func ParseFlags() (f Flags) {
|
||||||
f.SiteMode = siteMode
|
f.SiteMode = siteMode
|
||||||
f.SSLCertFile = certFile
|
f.SSLCertFile = certFile
|
||||||
f.SSLKeyFile = keyFile
|
f.SSLKeyFile = keyFile
|
||||||
|
f.DBType = dbType
|
||||||
|
|
||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ func main() {
|
||||||
rt.Product = env.ProdInfo{}
|
rt.Product = env.ProdInfo{}
|
||||||
rt.Product.Major = "1"
|
rt.Product.Major = "1"
|
||||||
rt.Product.Minor = "53"
|
rt.Product.Minor = "53"
|
||||||
rt.Product.Patch = "2"
|
rt.Product.Patch = "3"
|
||||||
rt.Product.Version = fmt.Sprintf("%s.%s.%s", rt.Product.Major, rt.Product.Minor, rt.Product.Patch)
|
rt.Product.Version = fmt.Sprintf("%s.%s.%s", rt.Product.Major, rt.Product.Minor, rt.Product.Patch)
|
||||||
rt.Product.Edition = "Community"
|
rt.Product.Edition = "Community"
|
||||||
rt.Product.Title = fmt.Sprintf("%s Edition", rt.Product.Edition)
|
rt.Product.Title = fmt.Sprintf("%s Edition", rt.Product.Edition)
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -67,7 +67,7 @@ export default Ember.Route.extend(ApplicationRouteMixin, TooltipMixin, {
|
||||||
console.log(transition); // eslint-disable-line no-console
|
console.log(transition); // eslint-disable-line no-console
|
||||||
|
|
||||||
if (netUtil.isAjaxAccessError(error) && !this.get('appMeta.setupMode')) {
|
if (netUtil.isAjaxAccessError(error) && !this.get('appMeta.setupMode')) {
|
||||||
localStorage.clearAll();
|
this.get('localStorage').clearAll();
|
||||||
return this.transitionTo('auth.login');
|
return this.transitionTo('auth.login');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border: none;
|
border: none;
|
||||||
border-bottom: 1px solid $color-input;
|
border-bottom: 1px solid $color-input;
|
||||||
height: 2.3rem;
|
height: 2.5rem;
|
||||||
outline: none;
|
outline: none;
|
||||||
|
|
||||||
&:focus {
|
&:focus {
|
||||||
|
@ -57,7 +57,7 @@
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
border: 1px solid $color-input;
|
border: 1px solid $color-input;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
height: 2.3rem;
|
height: 2.5rem;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "documize",
|
"name": "documize",
|
||||||
"version": "1.53.2",
|
"version": "1.53.3",
|
||||||
"description": "The Document IDE",
|
"description": "The Document IDE",
|
||||||
"private": true,
|
"private": true,
|
||||||
"repository": "",
|
"repository": "",
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
{
|
{
|
||||||
"community":
|
"community":
|
||||||
{
|
{
|
||||||
"version": "1.53.2",
|
"version": "1.53.3",
|
||||||
"major": 1,
|
"major": 1,
|
||||||
"minor": 53,
|
"minor": 53,
|
||||||
"patch": 2
|
"patch": 3
|
||||||
},
|
},
|
||||||
"enterprise":
|
"enterprise":
|
||||||
{
|
{
|
||||||
"version": "1.55.2",
|
"version": "1.55.3",
|
||||||
"major": 1,
|
"major": 1,
|
||||||
"minor": 55,
|
"minor": 55,
|
||||||
"patch": 2
|
"patch": 3
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue