From 3d2de29a9baf747f6a569abc912926ac647988f7 Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 28 Oct 2023 23:41:11 +0800 Subject: [PATCH] Refine env variable for bool. v5.11.7 --- DEVELOPER.md | 18 +++++++++--------- platform/candidate.go | 2 +- platform/cert.go | 2 +- platform/main.go | 6 +++--- platform/report.go | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/DEVELOPER.md b/DEVELOPER.md index 17b44377..2deb46fc 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -45,7 +45,7 @@ Run the platform backend, or run in GoLand: (cd platform && go run .) ``` -> Note: Set `AUTO_SELF_SIGNED_CERTIFICATE=true` if need to generate self-signed certificate. +> Note: Set `AUTO_SELF_SIGNED_CERTIFICATE=on` if need to generate self-signed certificate. Run all tests: @@ -870,12 +870,12 @@ The optional environments defined by `platform/containers/data/config/.env`: For feature control: -* `NAME_LOOKUP`: Whether enable the host name lookup, true or false. Default: false +* `NAME_LOOKUP`: `on|off`, whether enable the host name lookup, on or off. Default: off For testing the specified service: * `NODE_ENV`: `development|production`, if development, use local redis; otherwise, use `mgmt.srs.local` in docker. -* `LOCAL_RELEASE`: `true|false`, whether use local release service. +* `LOCAL_RELEASE`: `on|off`, whether use local release service. Default: off For mgmt and containers to connect to redis: @@ -895,16 +895,16 @@ Removed variables in .env: For HTTPS, automatically generate a self-signed certificate: -* `AUTO_SELF_SIGNED_CERTIFICATE`: `true|false`, whether generate self-signed certificate. +* `AUTO_SELF_SIGNED_CERTIFICATE`: `on|off`, whether generate self-signed certificate. Deprecated and unused variables: -* `SRS_DOCKERIZED`: `true|false` Indicates the OS is in docker. +* `SRS_DOCKERIZED`: `on|off`, indicates the OS is in docker. * `SRS_DOCKER`: `srs` to enfore use `ossrs/srs` docker image. -* `MGMT_DOCKER`: Whether run mgmt in docker. Default: false -* `PLATFORM_DOCKER`: Whether run platform in docker. Default: true -* `USE_DOCKER`: `true|false`, if false, disable all docker containers. -* `SRS_UTEST`: `true|false`, if true, running in utest mode. +* `MGMT_DOCKER`: `on|off`, whether run mgmt in docker. Default: false +* `PLATFORM_DOCKER`: `on|off`, whether run platform in docker. Default: on +* `USE_DOCKER`: `on|off`, if false, disable all docker containers. +* `SRS_UTEST`: `on|off`, if on, running in utest mode. * `SOURCE`: `github|gitee`, The source code for upgrading. Please restart service when `.env` changed. diff --git a/platform/candidate.go b/platform/candidate.go index addffc3a..36caf94b 100644 --- a/platform/candidate.go +++ b/platform/candidate.go @@ -48,7 +48,7 @@ func (v *CandidateWorker) Start(ctx context.Context) error { // set env NAME_LOOKUP to false. func (v *CandidateWorker) Resolve(host string) (net.IP, error) { // Ignore the resolving. - if os.Getenv("NAME_LOOKUP") == "false" { + if os.Getenv("NAME_LOOKUP") == "off" { return nil, nil } diff --git a/platform/cert.go b/platform/cert.go index afa0d242..7c9ea60e 100644 --- a/platform/cert.go +++ b/platform/cert.go @@ -49,7 +49,7 @@ func NewCertManager() *CertManager { } func (v *CertManager) Initialize(ctx context.Context) error { - if os.Getenv("AUTO_SELF_SIGNED_CERTIFICATE") == "true" { + if os.Getenv("AUTO_SELF_SIGNED_CERTIFICATE") == "on" { if err := v.createSelfSignCertificate(ctx); err != nil { return errors.Wrapf(err, "create self-signed certificate") } diff --git a/platform/main.go b/platform/main.go index a5cf5f30..7cf0fe4e 100644 --- a/platform/main.go +++ b/platform/main.go @@ -96,14 +96,14 @@ func doMain(ctx context.Context) error { // Migrate from mgmt. setEnvDefault("REDIS_PORT", "6379") setEnvDefault("MGMT_LISTEN", "2022") - setEnvDefault("PLATFORM_DOCKER", "true") + setEnvDefault("PLATFORM_DOCKER", "on") // For HTTPS. setEnvDefault("HTTPS_LISTEN", "2443") - setEnvDefault("AUTO_SELF_SIGNED_CERTIFICATE", "false") + setEnvDefault("AUTO_SELF_SIGNED_CERTIFICATE", "off") // For feature control. - setEnvDefault("NAME_LOOKUP", "false") + setEnvDefault("NAME_LOOKUP", "off") logger.Tf(ctx, "load .env as MGMT_PASSWORD=%vB, "+ "SRS_PLATFORM_SECRET=%vB, CLOUD=%v, REGION=%v, SOURCE=%v, "+ diff --git a/platform/report.go b/platform/report.go index b241e307..5eaa1621 100644 --- a/platform/report.go +++ b/platform/report.go @@ -214,7 +214,7 @@ func queryLatestVersion(ctx context.Context) (*Versions, error) { params["version"] = version params["ts"] = fmt.Sprintf("%v", time.Now().UnixNano()/int64(time.Millisecond)) releaseServer := "https://api.ossrs.net" - if os.Getenv("LOCAL_RELEASE") != "" { + if os.Getenv("LOCAL_RELEASE") == "on" { releaseServer = "http://localhost:2023" } logger.Tf(ctx, "Query %v with %v", releaseServer, params)