Skip to content
This repository was archived by the owner on Jan 23, 2022. It is now read-only.

Commit

Permalink
Work with env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyaglow committed Mar 29, 2018
1 parent 3f808ee commit b7f24b9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
7 changes: 3 additions & 4 deletions cmd/dor-insert-mongo/dor-insert-mongo.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"flag"
"os"
"time"

"github.com/ilyaglow/dor"
Expand All @@ -10,10 +10,9 @@ import (
const updatePeriod = time.Hour * 24

func main() {
mongoURL := flag.String("mongo", "", "MongoDB URL")
flag.Parse()
mongoURL := os.Getenv("DOR_MONGO_URL")

d, err := dor.New("mongodb", *mongoURL, false)
d, err := dor.New("mongodb", mongoURL, false)
if err != nil {
panic(err)
}
Expand Down
18 changes: 10 additions & 8 deletions service/dor-web-mongodb/dor-web-mongodb.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
package main

import (
"flag"
"fmt"
"os"

"github.com/ilyaglow/dor"
"github.com/ilyaglow/dor/web"
)

func main() {
bindAddr := flag.String("host", "127.0.0.1", "IP-address to bind")
bindPort := flag.String("port", "8080", "Port to bind")
mongoURL := flag.String("mongo", "", "MongoDB URL")
flag.Parse()
hp := fmt.Sprintf("%s:%s", *bindAddr, *bindPort)
var port string
if port = os.Getenv("DOR_PORT"); port == "" {
port = "8080"
}
port = fmt.Sprintf(":%s", port)

mongoURL := os.Getenv("DOR_MONGO_URL")

d, err := dor.New("mongodb", *mongoURL, false)
d, err := dor.New("mongodb", mongoURL, false)
if err != nil {
panic(err)
}

dorweb.Serve(hp, d)
dorweb.Serve(port, d)
}

0 comments on commit b7f24b9

Please sign in to comment.