Config: Rename "sql" / "internal" to "tidb" for more clarity

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer 2020-04-28 22:49:02 +02:00
parent 29bbdc7140
commit 8318ab8983
17 changed files with 106 additions and 106 deletions

View file

@ -15,13 +15,13 @@ assets-path: ~/.local/share/photoprism
resources-path: ~/.local/share/photoprism/resources
originals-path: ~/Pictures/Originals
import-path: ~/Pictures/Import
sql-host: localhost
sql-port: 4000
sql-password: photoprism
http-host:
http-mode: release
http-port: 2342
database-driver: internal
tidb-host: localhost
tidb-port: 4000
tidb-password: photoprism
database-driver: tidb
database-dsn: root:photoprism@tcp(localhost:4000)/photoprism?parseTime=true
pid-filename: ~/.local/share/photoprism/photoprism.pid
log-filename: ~/.local/share/photoprism/photoprism.log

View file

@ -12,23 +12,23 @@ services:
- "~/.cache/go-mod:/go/pkg/mod"
environment:
PHOTOPRISM_URL: "http://localhost:2342/"
PHOTOPRISM_UPLOAD_NSFW: "false"
PHOTOPRISM_DETECT_NSFW: "true"
PHOTOPRISM_PID_FILENAME: "photoprism.pid"
PHOTOPRISM_LOG_FILENAME: "photoprism.log"
PHOTOPRISM_DETACH_SERVER: "true"
PHOTOPRISM_HTTP_HOST: "0.0.0.0"
PHOTOPRISM_HTTP_PORT: 2342
PHOTOPRISM_TIDB_HOST: "0.0.0.0"
PHOTOPRISM_TIDB_PORT: 2343
PHOTOPRISM_TIDB_PASSWORD: "photoprism"
PHOTOPRISM_DATABASE_DRIVER: "tidb"
PHOTOPRISM_DATABASE_DSN: "root:photoprism@tcp(localhost:2343)/photoprism?parseTime=true"
PHOTOPRISM_TITLE: "PhotoPrism"
PHOTOPRISM_SUBTITLE: "Browse your life"
PHOTOPRISM_DESCRIPTION: "Personal Photo Management tested by Travis CI."
PHOTOPRISM_AUTHOR: "PhotoPrism.org"
PHOTOPRISM_TWITTER: "@browseyourlife"
PHOTOPRISM_HTTP_HOST: "0.0.0.0"
PHOTOPRISM_HTTP_PORT: 2342
PHOTOPRISM_SQL_HOST: "0.0.0.0"
PHOTOPRISM_SQL_PORT: 2343
PHOTOPRISM_SQL_PASSWORD: "photoprism"
PHOTOPRISM_DATABASE_DSN: "root:photoprism@tcp(localhost:2343)/photoprism?parseTime=true"
PHOTOPRISM_DATABASE_DRIVER: "internal"
PHOTOPRISM_PID_FILENAME: "photoprism.pid"
PHOTOPRISM_LOG_FILENAME: "photoprism.log"
PHOTOPRISM_DETACH_SERVER: "true"
PHOTOPRISM_UPLOAD_NSFW: "false"
PHOTOPRISM_DETECT_NSFW: "true"
CODECOV_TOKEN:
CODECOV_ENV:
CODECOV_URL:

View file

@ -14,10 +14,6 @@ services:
shm_size: "2gb"
environment:
PHOTOPRISM_URL: "http://localhost:2342/"
PHOTOPRISM_TITLE: "PhotoPrism"
PHOTOPRISM_SUBTITLE: "Browse your life"
PHOTOPRISM_AUTHOR: "PhotoPrism.org"
PHOTOPRISM_TWITTER: "@browseyourlife"
PHOTOPRISM_DEBUG: "true"
PHOTOPRISM_READONLY: "false"
PHOTOPRISM_PUBLIC: "false"
@ -25,6 +21,13 @@ services:
PHOTOPRISM_UPLOAD_NSFW: "false"
PHOTOPRISM_DETECT_NSFW: "true"
PHOTOPRISM_SERVER_MODE: "debug"
PHOTOPRISM_HTTP_HOST: "0.0.0.0"
PHOTOPRISM_HTTP_PORT: 2342
PHOTOPRISM_TIDB_HOST: "0.0.0.0"
PHOTOPRISM_TIDB_PORT: 2343
PHOTOPRISM_TIDB_PASSWORD: "photoprism"
PHOTOPRISM_DATABASE_DRIVER: "tidb"
PHOTOPRISM_DATABASE_DSN: "root:photoprism@tcp(localhost:2343)/photoprism?parseTime=true"
PHOTOPRISM_ASSETS_PATH: "/go/src/github.com/photoprism/photoprism/assets"
PHOTOPRISM_CACHE_PATH: "/go/src/github.com/photoprism/photoprism/assets/cache"
PHOTOPRISM_RESOURCES_PATH: "/go/src/github.com/photoprism/photoprism/assets/resources"
@ -32,13 +35,10 @@ services:
PHOTOPRISM_IMPORT_PATH: "/go/src/github.com/photoprism/photoprism/assets/photos/import"
PHOTOPRISM_TEMP_PATH: "/go/src/github.com/photoprism/photoprism/assets/photos/temp"
PHOTOPRISM_ORIGINALS_PATH: "/go/src/github.com/photoprism/photoprism/assets/photos/originals"
PHOTOPRISM_DATABASE_DRIVER: "internal"
PHOTOPRISM_DATABASE_DSN: "root:photoprism@tcp(localhost:2343)/photoprism?parseTime=true"
PHOTOPRISM_HTTP_HOST: "0.0.0.0"
PHOTOPRISM_HTTP_PORT: 2342
PHOTOPRISM_SQL_HOST: "0.0.0.0"
PHOTOPRISM_SQL_PORT: 2343
PHOTOPRISM_SQL_PASSWORD: "photoprism"
PHOTOPRISM_TITLE: "PhotoPrism"
PHOTOPRISM_SUBTITLE: "Browse your life"
PHOTOPRISM_AUTHOR: "PhotoPrism.org"
PHOTOPRISM_TWITTER: "@browseyourlife"
TF_CPP_MIN_LOG_LEVEL: 0
photoprism-db:

View file

@ -56,7 +56,7 @@ ENV PATH /photoprism/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin
ENV PHOTOPRISM_ORIGINALS_PATH /photoprism/originals
ENV PHOTOPRISM_IMPORT_PATH /photoprism/import
ENV PHOTOPRISM_SQL_PATH /photoprism/database
ENV PHOTOPRISM_TIDB_PATH /photoprism/database
ENV PHOTOPRISM_TEMP_PATH /photoprism/temp
ENV PHOTOPRISM_CACHE_PATH /photoprism/cache
ENV PHOTOPRISM_CONFIG_PATH /photoprism/config

View file

@ -140,7 +140,7 @@ ENV PATH /photoprism/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin
ENV PHOTOPRISM_ORIGINALS_PATH /photoprism/originals
ENV PHOTOPRISM_IMPORT_PATH /photoprism/import
ENV PHOTOPRISM_SQL_PATH /photoprism/database
ENV PHOTOPRISM_TIDB_PATH /photoprism/database
ENV PHOTOPRISM_TEMP_PATH /photoprism/temp
ENV PHOTOPRISM_CACHE_PATH /photoprism/cache
ENV PHOTOPRISM_CONFIG_PATH /photoprism/config

View file

@ -35,12 +35,12 @@ services:
PHOTOPRISM_DISABLE_SETTINGS: "false"
PHOTOPRISM_HTTP_HOST: "0.0.0.0"
PHOTOPRISM_HTTP_PORT: 2342
PHOTOPRISM_SQL_HOST: "0.0.0.0"
PHOTOPRISM_SQL_PORT: 2343 # Port for internal TiDB SQL server (driver "internal")
PHOTOPRISM_SQL_PASSWORD: "photoprism" # Plain text only (username "root")
PHOTOPRISM_TIDB_HOST: "0.0.0.0"
PHOTOPRISM_TIDB_PORT: 2343 # Port for built-in TiDB SQL server (driver "tidb")
PHOTOPRISM_TIDB_PASSWORD: "photoprism" # Plain text only (username "root")
PHOTOPRISM_ADMIN_PASSWORD: "photoprism" # Plain text or bcrypt hash (escape "$" with "$$")
PHOTOPRISM_WEBDAV_PASSWORD: "photoprism" # Plain text only (username "photoprism")
PHOTOPRISM_DATABASE_DRIVER: "internal" # Change to "mysql" for external MySQL or MariaDB
PHOTOPRISM_DATABASE_DRIVER: "tidb" # Change to "mysql" for external MySQL or MariaDB
PHOTOPRISM_DATABASE_DSN: "root:photoprism@tcp(localhost:2343)/photoprism?parseTime=true"
# PHOTOPRISM_THUMB_QUALITY: 95 # High-quality thumbnails (optional)
# PHOTOPRISM_THUMB_SIZE: 3840

View file

@ -34,12 +34,12 @@ services:
PHOTOPRISM_DISABLE_SETTINGS: "false"
PHOTOPRISM_HTTP_HOST: "0.0.0.0"
PHOTOPRISM_HTTP_PORT: 2342
PHOTOPRISM_SQL_HOST: "0.0.0.0"
PHOTOPRISM_SQL_PORT: 2343 # Port for internal TiDB SQL server (driver "internal")
PHOTOPRISM_SQL_PASSWORD: "photoprism" # Plain text only (username "root")
PHOTOPRISM_TIDB_HOST: "0.0.0.0"
PHOTOPRISM_TIDB_PORT: 2343 # Port for built-in TiDB SQL server (driver "tidb")
PHOTOPRISM_TIDB_PASSWORD: "photoprism" # Plain text only (username "root")
PHOTOPRISM_ADMIN_PASSWORD: "photoprism" # Plain text or bcrypt hash (escape "$" with "$$")
PHOTOPRISM_WEBDAV_PASSWORD: "photoprism" # Plain text only (username "photoprism")
PHOTOPRISM_DATABASE_DRIVER: "internal" # Change to "mysql" for external MySQL or MariaDB
PHOTOPRISM_DATABASE_DRIVER: "tidb" # Change to "mysql" for external MySQL or MariaDB
PHOTOPRISM_DATABASE_DSN: "root:photoprism@tcp(localhost:2343)/photoprism?parseTime=true"
# PHOTOPRISM_DATABASE_DRIVER: "mysql" # Using MariaDB or MySQL instead of the internal TiDB is optional
# PHOTOPRISM_DATABASE_DSN: "photoprism:photoprism@tcp(photoprism-db:3306)/photoprism?parseTime=true"

View file

@ -61,10 +61,10 @@ func configAction(ctx *cli.Context) error {
fmt.Printf("http-port %d\n", conf.HttpServerPort())
fmt.Printf("http-mode %s\n", conf.HttpServerMode())
fmt.Printf("sql-host %s\n", conf.SqlServerHost())
fmt.Printf("sql-port %d\n", conf.SqlServerPort())
fmt.Printf("sql-password %s\n", conf.SqlServerPassword())
fmt.Printf("sql-path %s\n", conf.SqlPath())
fmt.Printf("tidb-host %s\n", conf.TidbServerHost())
fmt.Printf("tidb-port %d\n", conf.TidbServerPort())
fmt.Printf("tidb-password %s\n", conf.TidbServerPassword())
fmt.Printf("tidb-path %s\n", conf.TidbServerPath())
fmt.Printf("database-driver %s\n", conf.DatabaseDriver())
fmt.Printf("database-dsn %s\n", conf.DatabaseDsn())

View file

@ -52,10 +52,10 @@ func startAction(ctx *cli.Context) error {
fmt.Printf("NAME VALUE\n")
fmt.Printf("detach-server %t\n", conf.DetachServer())
fmt.Printf("sql-host %s\n", conf.SqlServerHost())
fmt.Printf("sql-port %d\n", conf.SqlServerPort())
fmt.Printf("sql-password %s\n", conf.SqlServerPassword())
fmt.Printf("sql-path %s\n", conf.SqlPath())
fmt.Printf("tidb-host %s\n", conf.TidbServerHost())
fmt.Printf("tidb-port %d\n", conf.TidbServerPort())
fmt.Printf("tidb-password %s\n", conf.TidbServerPassword())
fmt.Printf("tidb-path %s\n", conf.TidbServerPath())
fmt.Printf("http-host %s\n", conf.HttpServerHost())
fmt.Printf("http-port %d\n", conf.HttpServerPort())

View file

@ -103,35 +103,35 @@ func TestConfig_DetachServer(t *testing.T) {
assert.Equal(t, false, detachServer)
}
func TestConfig_SqlServerHost(t *testing.T) {
func TestConfig_TidbServerHost(t *testing.T) {
ctx := CliTestContext()
c := NewConfig(ctx)
host := c.SqlServerHost()
host := c.TidbServerHost()
assert.Equal(t, "127.0.0.1", host)
}
func TestConfig_SqlServerPort(t *testing.T) {
func TestConfig_TidbServerPort(t *testing.T) {
ctx := CliTestContext()
c := NewConfig(ctx)
port := c.SqlServerPort()
port := c.TidbServerPort()
assert.Equal(t, uint(2343), port)
}
func TestConfig_SqlServerPath(t *testing.T) {
func TestConfig_TidbServerPath(t *testing.T) {
ctx := CliTestContext()
c := NewConfig(ctx)
path := c.SqlPath()
path := c.TidbServerPath()
assert.Equal(t, "/go/src/github.com/photoprism/photoprism/assets/resources/database", path)
}
func TestConfig_SqlServerPassword(t *testing.T) {
func TestConfig_TidbServerPassword(t *testing.T) {
ctx := CliTestContext()
c := NewConfig(ctx)
password := c.SqlServerPassword()
password := c.TidbServerPassword()
assert.Equal(t, "", password)
}
@ -222,7 +222,7 @@ func TestConfig_DatabaseDriver(t *testing.T) {
c := NewConfig(ctx)
driver := c.DatabaseDriver()
assert.Equal(t, "internal", driver)
assert.Equal(t, DriverTidb, driver)
}
func TestConfig_DatabaseDsn(t *testing.T) {
@ -230,7 +230,7 @@ func TestConfig_DatabaseDsn(t *testing.T) {
c := NewConfig(ctx)
dsn := c.DatabaseDriver()
assert.Equal(t, "internal", dsn)
assert.Equal(t, DriverTidb, dsn)
}
func TestConfig_CachePath(t *testing.T) {

View file

@ -18,11 +18,11 @@ import (
// DatabaseDriver returns the database driver name.
func (c *Config) DatabaseDriver() string {
if c.params.DatabaseDriver == "" {
return DbTiDB
if strings.ToLower(c.params.DatabaseDriver) == "mysql" {
return DriverMysql
}
return c.params.DatabaseDriver
return DriverTidb
}
// DatabaseDsn returns the database data source name (DSN).
@ -144,17 +144,17 @@ func (c *Config) connectToDatabase(ctx context.Context) error {
isTiDB := false
initSuccess := false
if dbDriver == DbTiDB {
if dbDriver == DriverTidb {
isTiDB = true
dbDriver = DbMySQL
dbDriver = DriverMysql
}
db, err := gorm.Open(dbDriver, dbDsn)
if err != nil || db == nil {
if isTiDB {
log.Infof("starting database server at %s:%d\n", c.SqlServerHost(), c.SqlServerPort())
log.Infof("starting database server at %s:%d\n", c.TidbServerHost(), c.TidbServerPort())
go tidb.Start(ctx, c.SqlPath(), c.SqlServerPort(), c.SqlServerHost(), c.Debug())
go tidb.Start(ctx, c.TidbServerPath(), c.TidbServerPort(), c.TidbServerHost(), c.Debug())
}
for i := 1; i <= 12; i++ {
@ -167,7 +167,7 @@ func (c *Config) connectToDatabase(ctx context.Context) error {
}
if isTiDB && !initSuccess {
err = tidb.InitDatabase(c.SqlServerPort(), c.SqlServerPassword())
err = tidb.InitDatabase(c.TidbServerPort(), c.TidbServerPassword())
if err != nil {
log.Debug(err)

View file

@ -61,8 +61,8 @@ func (c *Config) CreateDirectories() error {
return createError(c.ResourcesPath(), err)
}
if err := os.MkdirAll(c.SqlPath(), os.ModePerm); err != nil {
return createError(c.SqlPath(), err)
if err := os.MkdirAll(c.TidbServerPath(), os.ModePerm); err != nil {
return createError(c.TidbServerPath(), err)
}
if err := os.MkdirAll(c.TensorFlowModelPath(), os.ModePerm); err != nil {

View file

@ -190,30 +190,30 @@ var GlobalFlags = []cli.Flag{
EnvVar: "PHOTOPRISM_HTTP_MODE",
},
cli.IntFlag{
Name: "sql-port",
Name: "tidb-port",
Value: 2343,
Usage: "built-in SQL server port",
EnvVar: "PHOTOPRISM_SQL_PORT",
Usage: "built-in TiDB server port",
EnvVar: "PHOTOPRISM_TIDB_PORT",
},
cli.StringFlag{
Name: "sql-host",
Usage: "built-in SQL server host",
EnvVar: "PHOTOPRISM_SQL_HOST",
Name: "tidb-host",
Usage: "built-in TiDB server host",
EnvVar: "PHOTOPRISM_TIDB_HOST",
},
cli.StringFlag{
Name: "sql-password",
Usage: "built-in SQL server password",
EnvVar: "PHOTOPRISM_SQL_PASSWORD",
Name: "tidb-password",
Usage: "built-in TiDB server password",
EnvVar: "PHOTOPRISM_TIDB_PASSWORD",
},
cli.StringFlag{
Name: "sql-path",
Usage: "built-in database server storage path",
EnvVar: "PHOTOPRISM_SQL_PATH",
Name: "tidb-path",
Usage: "built-in TiDB server storage path",
EnvVar: "PHOTOPRISM_TIDB_PATH",
},
cli.StringFlag{
Name: "database-driver",
Usage: "database `DRIVER` (internal or mysql)",
Value: "internal",
Usage: "database `DRIVER` (tidb or mysql)",
Value: "tidb",
EnvVar: "PHOTOPRISM_DATABASE_DRIVER",
},
cli.StringFlag{

View file

@ -15,8 +15,8 @@ import (
// define database drivers const
const (
DbTiDB = "internal"
DbMySQL = "mysql"
DriverTidb = "tidb"
DriverMysql = "mysql"
)
// Params provides a struct in which application configuration is stored.
@ -56,10 +56,10 @@ type Params struct {
ResourcesPath string `yaml:"resources-path" flag:"resources-path"`
DatabaseDriver string `yaml:"database-driver" flag:"database-driver"`
DatabaseDsn string `yaml:"database-dsn" flag:"database-dsn"`
SqlServerHost string `yaml:"sql-host" flag:"sql-host"`
SqlServerPort uint `yaml:"sql-port" flag:"sql-port"`
SqlServerPassword string `yaml:"sql-password" flag:"sql-password"`
SqlServerPath string `yaml:"sql-path" flag:"sql-path"`
TidbServerHost string `yaml:"tidb-host" flag:"tidb-host"`
TidbServerPort uint `yaml:"tidb-port" flag:"tidb-port"`
TidbServerPassword string `yaml:"tidb-password" flag:"tidb-password"`
TidbServerPath string `yaml:"tidb-path" flag:"tidb-path"`
HttpServerHost string `yaml:"http-host" flag:"http-host"`
HttpServerPort int `yaml:"http-port" flag:"http-port"`
HttpServerMode string `yaml:"http-mode" flag:"http-mode"`
@ -116,7 +116,7 @@ func (c *Params) expandFilenames() {
c.OriginalsPath = fs.Abs(c.OriginalsPath)
c.ImportPath = fs.Abs(c.ImportPath)
c.TempPath = fs.Abs(c.TempPath)
c.SqlServerPath = fs.Abs(c.SqlServerPath)
c.TidbServerPath = fs.Abs(c.TidbServerPath)
c.PIDFilename = fs.Abs(c.PIDFilename)
c.LogFilename = fs.Abs(c.LogFilename)
}

View file

@ -36,7 +36,7 @@ func TestParams_SetValuesFromFile(t *testing.T) {
assert.Equal(t, "/srv/photoprism/photos/originals", c.OriginalsPath)
assert.Equal(t, "/srv/photoprism/photos/import", c.ImportPath)
assert.Equal(t, "/srv/photoprism/temp", c.TempPath)
assert.Equal(t, "internal", c.DatabaseDriver)
assert.Equal(t, DriverTidb, c.DatabaseDriver)
assert.Equal(t, "root:photoprism@tcp(localhost:2343)/photoprism?parseTime=true", c.DatabaseDsn)
assert.Equal(t, 81, c.HttpServerPort)
}

View file

@ -63,34 +63,34 @@ func (c *Config) HttpStaticBuildPath() string {
return c.HttpStaticPath() + "/build"
}
// SqlServerHost returns the built-in SQL server host name or IP address (empty for all interfaces).
func (c *Config) SqlServerHost() string {
if c.params.SqlServerHost == "" {
// TidbServerHost returns the host for the built-in TiDB server. (empty for all interfaces).
func (c *Config) TidbServerHost() string {
if c.params.TidbServerHost == "" {
return "127.0.0.1"
}
return c.params.SqlServerHost
return c.params.TidbServerHost
}
// SqlServerPort returns the built-in SQL server port.
func (c *Config) SqlServerPort() uint {
if c.params.SqlServerPort == 0 {
// TidbServerPort returns the port for the built-in TiDB server.
func (c *Config) TidbServerPort() uint {
if c.params.TidbServerPort == 0 {
return 2343
}
return c.params.SqlServerPort
return c.params.TidbServerPort
}
// SqlServerPassword returns the password for the built-in database server.
func (c *Config) SqlServerPassword() string {
return c.params.SqlServerPassword
// TidbServerPassword returns the password for the built-in TiDB server.
func (c *Config) TidbServerPassword() string {
return c.params.TidbServerPassword
}
// SqlPath returns the database storage path for the built-in SQL server.
func (c *Config) SqlPath() string {
if c.params.SqlServerPath == "" {
// TidbServerPath returns the database storage path for the built-in TiDB server.
func (c *Config) TidbServerPath() string {
if c.params.TidbServerPath == "" {
return c.ResourcesPath() + "/database"
}
return fs.Abs(c.params.SqlServerPath)
return fs.Abs(c.params.TidbServerPath)
}

View file

@ -5,14 +5,14 @@ cache-path: /srv/photoprism/cache
originals-path: /srv/photoprism/photos/originals
import-path: /srv/photoprism/photos/import
temp-path: /srv/photoprism/temp
sql-host: localhost
sql-port: 2343
sql-password: photoprism
http-host:
http-mode: release
http-port: 81
http-password:
database-driver: internal
tidb-host: localhost
tidb-port: 2343
tidb-password: photoprism
database-driver: tidb
database-dsn: root:photoprism@tcp(localhost:2343)/photoprism?parseTime=true
theme: lavendel
language: english