1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-12 05:20:26 +00:00

Add a -listen-addr flag, remove LISTEN_ADDR/PORT

This commit is contained in:
handlerug 2021-07-06 02:47:07 +07:00
parent 295c209472
commit cfc413f1a9
No known key found for this signature in database
GPG Key ID: 38009F0605051491
2 changed files with 4 additions and 9 deletions

View File

@ -137,21 +137,15 @@ func ReadConfigFile(path string) error {
// doesn't exist or is empty.
f.MapTo(cfg)
if os.Getenv("LISTEN_ADDR") != "" {
cfg.Network.ListenAddr = os.Getenv("LISTEN_ADDR")
}
if os.Getenv("PORT") != "" {
cfg.Network.ListenAddr = "127.0.0.1:" + os.Getenv("PORT")
}
// Map the struct to the global variables
WikiName = cfg.WikiName
NaviTitleIcon = cfg.NaviTitleIcon
HomeHypha = cfg.HomeHypha
UserHypha = cfg.UserHypha
HeaderLinksHypha = cfg.HeaderLinksHypha
if ListenAddr == "" {
ListenAddr = cfg.ListenAddr
}
URL = cfg.URL
UseAuth = cfg.UseAuth
AllowRegistration = cfg.AllowRegistration

View File

@ -36,6 +36,7 @@ type CreateUserCommand struct {
func parseCliArgs() {
var createAdminName string
flag.StringVar(&cfg.ListenAddr, "listen-addr", "", "Address to listen on. For example, 127.0.0.1:1737 or /run/mycorrhiza.sock.")
flag.StringVar(&createAdminName, "create-admin", "", "Create a new admin. The password will be prompted in the terminal.")
flag.Usage = printHelp
flag.Parse()