Skip to content

Commit

Permalink
main: Use port from go-micro env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
nkprince007 committed May 23, 2018
1 parent ba5fc19 commit 280b07c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@

GOPATH:=$(shell go env GOPATH)

.PHONY: proto test docker
.PHONY: test docker run build


build:
go build -o listen

run: build
MICRO_SERVER_ADDRESS=:8000 ./listen

test:
go test -v ./... -cover

Expand Down
13 changes: 0 additions & 13 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"fmt"
"os"

_ "github.com/micro/go-plugins/broker/rabbitmq"

Expand All @@ -11,13 +10,6 @@ import (
"gitlab.com/nkprince007/listen/handler"
)

func getEnv(key string, fallback string) string {
if value, ok := os.LookupEnv(key); ok {
return value
}
return fallback
}

func main() {
fmt.Print(`
___ __
Expand All @@ -28,15 +20,10 @@ func main() {
`)

// grab port from environment
port := getEnv("PORT", "8000")

// create new web service
service := web.NewService(
web.Name("go.micro.web.listen"),
web.Version("latest"),
web.Address(":"+port),
)

// register call handler
Expand Down

0 comments on commit 280b07c

Please sign in to comment.