我已经在 Heroku 上部署了 Go 应用程序,但是在点击 url 时......它没有给出正确的响应。Heroku 日志看起来像这样:2015-06-27T10:43:06.839094+00:00 heroku[web.1]: Starting process with command `FlickrImage`2015-06-27T10:43:08.998400+00:00 heroku[web.1]: State changed from starting to crashed2015-06-27T10:43:08.998400+00:00 heroku[web.1]: State changed from crashed to starting2015-06-27T10:43:08.985737+00:00 heroku[web.1]: Process exited with status 02015-06-27T10:43:10.795684+00:00 heroku[web.1]: Starting process with command `FlickrImage`2015-06-27T10:43:13.837301+00:00 heroku[web.1]: Process exited with status 02015-06-27T10:43:13.850141+00:00 heroku[web.1]: State changed from starting to crashed2015-06-27T10:44:41.914412+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/Index" host=morning-ridge-1365.herokuapp.com request_id=89d2e794-a725-4ddf-b437-dbcbd988428c fwd="202.12.83.44" dyno= connect= service= status=503 bytes=FlickrImage 是我的 go 文件,我创建了一个包含“web: FlickrImage”的 Procfile编辑:FlickrImageServer 代码:package mainimport ( "encoding/json" "fmt" "io/ioutil" "log" "net/http" "os" "reflect" "strconv" "strings" "github.com/gorilla/mux" "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson")type imageLinks struct { Link string `bson:"link"` Upvote int `bson:"upvote"` Downvote int `bson:"downvote"`}任何帮助,将不胜感激
1 回答
猛跑小猪
TA贡献1858条经验 获得超8个赞
Heroku dynos动态分配端口。您的应用程序可能崩溃了,因为它无法绑定到端口 8080。
改变这一行:
log.Fatal(http.ListenAndServe(":8080", router))
...到这个:
port := ":" + os.Getenv("PORT")
log.Fatal(http.ListenAndServe(port, router))
- 1 回答
- 0 关注
- 191 浏览
添加回答
举报
0/150
提交
取消