Skip to content

Commit

Permalink
Merge pull request #15 from kubero-dev/fix/environment-variables-ignored
Browse files Browse the repository at this point in the history
fix env vars
  • Loading branch information
mms-gianni authored Nov 8, 2023
2 parents 719373b + afca5ed commit 8058ebf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
14 changes: 5 additions & 9 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"ladder/handlers"
"log"
"os"
"strconv"
"strings"

"github.com/akamensky/argparse"
Expand All @@ -23,27 +22,24 @@ func main() {

parser := argparse.NewParser("ladder", "Every Wall needs a Ladder")

p := os.Getenv("PORT")
if os.Getenv("PORT") == "" {
p = "8080"
}
port := parser.String("p", "port", &argparse.Options{
Required: false,
Default: p,
Default: os.Getenv("PORT"),
Help: "Port the webserver will listen on"})

pf, _ := strconv.ParseBool(os.Getenv("PREFORK"))

prefork := parser.Flag("P", "prefork", &argparse.Options{
Required: false,
Default: pf,
Help: "This will spawn multiple processes listening"})

err := parser.Parse(os.Args)
if err != nil {
fmt.Print(parser.Usage(err))
}

if os.Getenv("PREFORK") == "true" {
*prefork = true
}

app := fiber.New(
fiber.Config{
Prefork: *prefork,
Expand Down
2 changes: 1 addition & 1 deletion handlers/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func fetchSite(urlpath string, queries map[string]string) (string, *http.Request
return "", nil, nil, fmt.Errorf("domain not allowed. %s not in %s", u.Host, allowedDomains)
}

if os.Getenv("DEBUG ") == "true" {
if os.Getenv("LOG_URLS ") == "true" {
log.Println(u.String() + urlQuery)
}

Expand Down

0 comments on commit 8058ebf

Please sign in to comment.