Skip to content

Commit b1bfff8

Browse files
author
Nicolás Gudiño
committed
Add environment loading for WUZAPI_PORT and WUZAPI_ADDRESS. Should fix issue #239
1 parent 9127c95 commit b1bfff8

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

.env.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# .env
22
# Server Configuration
33
WUZAPI_PORT=8080
4+
WUZAPI_ADDRESS=0.0.0.0
45

56
# Token for WuzAPI Admin
67
WUZAPI_ADMIN_TOKEN=1234ABCD

main.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,22 @@ func main() {
180180

181181
flag.Parse()
182182

183+
// Check for address in environment variable if flag is default or empty
184+
if *address == "0.0.0.0" || *address == "" {
185+
if v := os.Getenv("WUZAPI_ADDRESS"); v != "" {
186+
*address = v
187+
log.Info().Str("address", v).Msg("Address configured from environment variable")
188+
}
189+
}
190+
191+
// Check for port in environment variable if flag is default or empty
192+
if *port == "8080" || *port == "" {
193+
if v := os.Getenv("WUZAPI_PORT"); v != "" {
194+
*port = v
195+
log.Info().Str("port", v).Msg("Port configured from environment variable")
196+
}
197+
}
198+
183199
if v := os.Getenv("WEBHOOK_RETRY_ENABLED"); v != "" {
184200
*webhookRetryEnabled = strings.ToLower(v) == "true" || v == "1"
185201
}

0 commit comments

Comments
 (0)