mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-11 13:47:28 -06:00
add host and protocol options
This commit is contained in:
parent
4194f8d88f
commit
555e254649
3 changed files with 39 additions and 0 deletions
|
|
@ -58,6 +58,18 @@ func main() {
|
||||||
Value: "",
|
Value: "",
|
||||||
EnvVars: []string{envNames.ConfigPath},
|
EnvVars: []string{envNames.ConfigPath},
|
||||||
},
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: flagNames.Host,
|
||||||
|
Usage: "Hostname to use for the server (eg., example.org, gotosocial.whatever.com)",
|
||||||
|
Value: "localhost",
|
||||||
|
EnvVars: []string{envNames.Host},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: flagNames.Protocol,
|
||||||
|
Usage: "Protocol to use for the REST api of the server (only use http for debugging and tests!)",
|
||||||
|
Value: "https",
|
||||||
|
EnvVars: []string{envNames.Protocol},
|
||||||
|
},
|
||||||
|
|
||||||
// DATABASE FLAGS
|
// DATABASE FLAGS
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,17 @@ logLevel: "info"
|
||||||
# Default: "gotosocial"
|
# Default: "gotosocial"
|
||||||
applicationName: "gotosocial"
|
applicationName: "gotosocial"
|
||||||
|
|
||||||
|
# String. Hostname/domain to use for the server. Defaults to localhost for local testing,
|
||||||
|
# but you should *definitely* change this when running for real, or your server won't work at all.
|
||||||
|
# Examples: ["example.org","some.server.com"]
|
||||||
|
# Default: "localhost"
|
||||||
|
host: "localhost"
|
||||||
|
|
||||||
|
# String. Protocol to use for the server. Only change to http for local testing!
|
||||||
|
# Options: ["http","https"]
|
||||||
|
# Default: "https"
|
||||||
|
protocol: "https"
|
||||||
|
|
||||||
# Config pertaining to the Gotosocial database connection
|
# Config pertaining to the Gotosocial database connection
|
||||||
db:
|
db:
|
||||||
# String. Database type.
|
# String. Database type.
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ import (
|
||||||
type Config struct {
|
type Config struct {
|
||||||
LogLevel string `yaml:"logLevel"`
|
LogLevel string `yaml:"logLevel"`
|
||||||
ApplicationName string `yaml:"applicationName"`
|
ApplicationName string `yaml:"applicationName"`
|
||||||
|
Host string `yaml:"host"`
|
||||||
|
Protocol string `yaml:"protocol"`
|
||||||
DBConfig *DBConfig `yaml:"db"`
|
DBConfig *DBConfig `yaml:"db"`
|
||||||
TemplateConfig *TemplateConfig `yaml:"template"`
|
TemplateConfig *TemplateConfig `yaml:"template"`
|
||||||
}
|
}
|
||||||
|
|
@ -97,6 +99,14 @@ func (c *Config) ParseCLIFlags(f KeyedFlags) {
|
||||||
c.ApplicationName = f.String(fn.ApplicationName)
|
c.ApplicationName = f.String(fn.ApplicationName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.Host == "" || f.IsSet(fn.Host) {
|
||||||
|
c.Host = f.String(fn.Host)
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.Protocol == "" || f.IsSet(fn.Protocol) {
|
||||||
|
c.Protocol = f.String(fn.Protocol)
|
||||||
|
}
|
||||||
|
|
||||||
// db flags
|
// db flags
|
||||||
if c.DBConfig.Type == "" || f.IsSet(fn.DbType) {
|
if c.DBConfig.Type == "" || f.IsSet(fn.DbType) {
|
||||||
c.DBConfig.Type = f.String(fn.DbType)
|
c.DBConfig.Type = f.String(fn.DbType)
|
||||||
|
|
@ -142,6 +152,8 @@ type Flags struct {
|
||||||
LogLevel string
|
LogLevel string
|
||||||
ApplicationName string
|
ApplicationName string
|
||||||
ConfigPath string
|
ConfigPath string
|
||||||
|
Host string
|
||||||
|
Protocol string
|
||||||
DbType string
|
DbType string
|
||||||
DbAddress string
|
DbAddress string
|
||||||
DbPort string
|
DbPort string
|
||||||
|
|
@ -158,6 +170,8 @@ func GetFlagNames() Flags {
|
||||||
LogLevel: "log-level",
|
LogLevel: "log-level",
|
||||||
ApplicationName: "application-name",
|
ApplicationName: "application-name",
|
||||||
ConfigPath: "config-path",
|
ConfigPath: "config-path",
|
||||||
|
Host: "host",
|
||||||
|
Protocol: "protocol",
|
||||||
DbType: "db-type",
|
DbType: "db-type",
|
||||||
DbAddress: "db-address",
|
DbAddress: "db-address",
|
||||||
DbPort: "db-port",
|
DbPort: "db-port",
|
||||||
|
|
@ -175,6 +189,8 @@ func GetEnvNames() Flags {
|
||||||
LogLevel: "GTS_LOG_LEVEL",
|
LogLevel: "GTS_LOG_LEVEL",
|
||||||
ApplicationName: "GTS_APPLICATION_NAME",
|
ApplicationName: "GTS_APPLICATION_NAME",
|
||||||
ConfigPath: "GTS_CONFIG_PATH",
|
ConfigPath: "GTS_CONFIG_PATH",
|
||||||
|
Host: "GTS_HOST",
|
||||||
|
Protocol: "GTS_PROTOCOL",
|
||||||
DbType: "GTS_DB_TYPE",
|
DbType: "GTS_DB_TYPE",
|
||||||
DbAddress: "GTS_DB_ADDRESS",
|
DbAddress: "GTS_DB_ADDRESS",
|
||||||
DbPort: "GTS_DB_PORT",
|
DbPort: "GTS_DB_PORT",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue