Skip to content

Commit dd984be

Browse files
committed
support heroku
1 parent b9fe92f commit dd984be

File tree

5 files changed

+20
-17
lines changed

5 files changed

+20
-17
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PROT=8080

Procfile.local

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: go run main.go

README.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
## Usage
22

3-
```
4-
go run main.go
5-
6-
go run main.go -client
7-
```
8-
9-
request http://localhost:8080/ through postman
10-
11-
3+
## Debug stage
124

135
[Data Race Detector](https://go.dev/doc/articles/race_detector)
14-
156
```
167
go run -race main.go
178
189
go run -race main.go -client
1910
```
11+
request http://localhost:8080/ through postman
2012

13+
## Development with Heroku locally
14+
```
15+
//start server locally
16+
heroku local -f Procfile.local
17+
18+
//start client locally
19+
go run main.go -client
20+
```
2121

2222
## Deploy to Heroku
2323

@@ -29,4 +29,7 @@ heroku create
2929
git push heroku main
3030
//open you app in browser
3131
heroku open
32+
33+
//check logs
34+
heroku logs --tail
3235
```

core/ggrok-client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"github.com/gorilla/websocket"
1717
)
1818

19-
var addr = flag.String("addr", "localhost:8080", "http service address")
19+
var addr = flag.String("addr", "localhost:5000", "http service address")
2020

2121
type GGrokClient struct {
2222
}

main.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ func main() {
1919
flag.Parse()
2020
log.SetFlags(0)
2121

22-
port := os.Getenv("PORT")
23-
24-
if port == "" {
25-
log.Fatal("$PORT must be set")
26-
}
27-
2822
if client {
2923
done := make(chan struct{})
3024
go func() {
@@ -37,6 +31,10 @@ func main() {
3731
<-done
3832
}
3933

34+
port := os.Getenv("PORT")
35+
if port == "" {
36+
log.Fatal("$PORT must be set")
37+
}
4038
s := core.NewServer()
4139

4240
http.HandleFunc("/$$ggrok", s.Register)

0 commit comments

Comments
 (0)