File tree 4 files changed +17
-7
lines changed
4 files changed +17
-7
lines changed Original file line number Diff line number Diff line change
1
+ gin-bin
Original file line number Diff line number Diff line change @@ -4,4 +4,6 @@ WORKDIR /go/src/github.com/maxcnunes/monitor-api
4
4
5
5
ADD . /go/src/github.com/maxcnunes/monitor-api
6
6
7
- RUN go get -d ./...
7
+ RUN go get -d ./...
8
+
9
+ RUN go get github.com/codegangsta/gin
Original file line number Diff line number Diff line change 3
3
4
4
local :
5
5
build : .
6
- command : go run main.go
6
+ command : gin
7
7
ports :
8
8
- 3000
9
9
volumes :
13
13
MONGODB_DATABASE : monitor-api
14
14
VIRTUAL_PORT : 3000
15
15
VIRTUAL_HOST : monitor-service.local.bravi.com.br
16
+ PORT_BEHIND_PROXY : 3001
16
17
links :
17
18
- mongo:mongo
Original file line number Diff line number Diff line change 1
1
package main
2
2
3
3
import (
4
- "flag"
5
4
"github.com/maxcnunes/monitor-api/monitor"
6
5
"github.com/maxcnunes/monitor-api/server"
7
6
"log"
8
7
"net/http"
8
+ "os"
9
9
)
10
10
11
11
var (
12
12
db = monitor.DB {}
13
13
data = monitor.DataMonitor {}
14
14
router = server.Router {}
15
15
websocket = server.Websocket {}
16
- addr = flag .String ("addr" , ":3000" , "http service address" )
17
16
)
18
17
19
18
func main () {
20
- flag .Parse ()
19
+ var addr string
20
+ if env := os .Getenv ("PORT_BEHIND_PROXY" ); env != "" {
21
+ addr = ":" + env
22
+ } else if env := os .Getenv ("VIRTUAL_PORT" ); env != "" {
23
+ addr = ":" + env
24
+ } else {
25
+ addr = ":3000"
26
+ }
21
27
22
28
db .Start ()
23
29
defer db .Close ()
@@ -27,8 +33,8 @@ func main() {
27
33
http .Handle ("/" , router .Start (& data ))
28
34
http .HandleFunc ("/ws" , websocket .Start (& data ))
29
35
30
- log .Printf ("Server running on http://0.0.0.0:%d " , * addr )
31
- if err := http .ListenAndServe (* addr , nil ); err != nil {
36
+ log .Printf ("Server running on http://%s " , addr )
37
+ if err := http .ListenAndServe (addr , nil ); err != nil {
32
38
log .Fatal ("ListenAndServe: " , err )
33
39
}
34
40
}
You can’t perform that action at this time.
0 commit comments