Move server flags to global config, see #50

This commit is contained in:
Michael Mayer 2018-12-21 04:17:22 +01:00
parent b300d5540c
commit 5345ad37a2
2 changed files with 48 additions and 12 deletions

View File

@ -63,4 +63,40 @@ var GlobalFlags = []cli.Flag{
Value: "root:@tcp(localhost:4000)/photoprism?parseTime=true",
EnvVar: "PHOTOPRISM_DATABASE_DSN",
},
cli.IntFlag{
Name: "http-port, p",
Usage: "HTTP server port",
Value: 80,
EnvVar: "PHOTOPRISM_HTTP_PORT",
},
cli.StringFlag{
Name: "http-host, i",
Usage: "HTTP server host",
Value: "",
EnvVar: "PHOTOPRISM_HTTP_HOST",
},
cli.StringFlag{
Name: "http-mode, m",
Usage: "debug, release or test",
Value: "",
EnvVar: "PHOTOPRISM_HTTP_MODE",
},
cli.IntFlag{
Name: "sql-port, s",
Usage: "SQL server port",
Value: 4000,
EnvVar: "PHOTOPRISM_SQL_PORT",
},
cli.StringFlag{
Name: "sql-host",
Usage: "SQL server host",
Value: "",
EnvVar: "PHOTOPRISM_SQL_HOST",
},
cli.StringFlag{
Name: "sql-path",
Usage: "SQL server storage path",
Value: "",
EnvVar: "PHOTOPRISM_SQL_PATH",
},
}

View File

@ -180,28 +180,28 @@ func (c *Config) SetValuesFromCliContext(ctx *cli.Context) error {
c.databaseDsn = ctx.GlobalString("database-dsn")
}
if ctx.IsSet("sql-host") || c.sqlServerHost == "" {
c.sqlServerHost = ctx.String("sql-host")
if ctx.GlobalIsSet("sql-host") || c.sqlServerHost == "" {
c.sqlServerHost = ctx.GlobalString("sql-host")
}
if ctx.IsSet("sql-port") || c.sqlServerPort == 0 {
c.sqlServerPort = ctx.Uint("sql-port")
if ctx.GlobalIsSet("sql-port") || c.sqlServerPort == 0 {
c.sqlServerPort = ctx.GlobalUint("sql-port")
}
if ctx.IsSet("sql-path") || c.sqlServerPath == "" {
c.sqlServerPath = ctx.String("sql-path")
if ctx.GlobalIsSet("sql-path") || c.sqlServerPath == "" {
c.sqlServerPath = ctx.GlobalString("sql-path")
}
if ctx.IsSet("http-host") || c.httpServerHost == "" {
c.httpServerHost = ctx.String("http-host")
if ctx.GlobalIsSet("http-host") || c.httpServerHost == "" {
c.httpServerHost = ctx.GlobalString("http-host")
}
if ctx.IsSet("http-port") || c.httpServerPort == 0 {
c.httpServerPort = ctx.Int("http-port")
if ctx.GlobalIsSet("http-port") || c.httpServerPort == 0 {
c.httpServerPort = ctx.GlobalInt("http-port")
}
if ctx.IsSet("http-mode") || c.httpServerMode == "" {
c.httpServerMode = ctx.String("http-mode")
if ctx.GlobalIsSet("http-mode") || c.httpServerMode == "" {
c.httpServerMode = ctx.GlobalString("http-mode")
}
return nil