简体   繁体   English

使用Elastic Beanstalk在AWS上转到Web应用程序,而不显示日志中的输出

[英]Go Web app on AWS with Elastic Beanstalk not showing output in logs

This is sort of an in-depth question, so I'll try to explain it as best I can. 这是一个深入的问题,所以我会尽力解释它。

I've built a small API service in Go that I'm trying to deploy to AWS using the relatively new AWS Elastic Beanstalk Docker support . 我在Go中构建了一个小型API服务,我尝试使用相对较新的AWS Elastic Beanstalk Docker 支持部署到AWS。

Here's what I've done (the code is all open source, so you can follow along if you'd like): 这就是我所做的(代码是全部开源的,所以如果你愿意,你可以跟随):

$ git clone https://github.com/rdegges/ipify-api.git
$ cd ipify-api
$ git fetch origin aws:aws
$ git checkout aws
$ eb init
$ eb create
$ eb deploy

This will use elastic beanstalk to create a new app (with docker), and deploy it. 这将使用弹性beanstalk创建一个新的应用程序(与docker),并部署它。

If I then run eb open to open my web app, I'll see my public IP address displayed (this is the correct behavior), so I know that my application is running / functional. 如果我然后eb open我的网络应用程序,我会看到我的公共IP地址显示(这是正确的行为),所以我知道我的应用程序正在运行/功能。

Now, in my source code, I've got several lines of debugging output: 现在,在我的源代码中,我有几行调试输出:

fmt.Println("WOOOOOOOOOOOO")

The above statement just prints "WOO…" to the console. 上面的语句只是将“WOO ...”打印到控制台。 This is run every time a new request is made. 每次发出新请求时都会运行此操作。

Unfortunately, when I run eb logs to view my instance logs, this debug line never shows up – and I can't figure out why. 不幸的是,当我运行eb logs来查看我的实例日志时,这个调试行永远不会出现 - 我无法弄清楚原因。

I've tried printing to STDERR, printing to STDOUT, etc. – but I'm absolutely unable to get any output. 我已经尝试打印到STDERR,打印到STDOUT等 - 但我绝对无法获得任何输出。

I've scoured the internet looking for solutions, but have yet to find any. 我已经在互联网上寻找解决方案,但还没有找到任何解决方案。

I think import "github.com/rdegges/ipify-api/api" is being built from the copy on Github, not from the local copy. 我认为import "github.com/rdegges/ipify-api/api"是从Github上的副本构建的,而不是从本地副本构建的。 The most recent commit of the api package doesn't have the extraneous fmt statements. api包的最新提交没有无关的fmt语句。 Also, the log statement in main.go works fine, as does the fmt.Fprintf already in the api package. 此外, main.golog语句工作正常, api包中已有fmt.Fprintf Try to verify the api package is getting built from the source you think it is. 尝试验证api包是从您认为的源构建的。

EDIT 6/1/2015: 编辑6/1/2015:

All my tests indicate this is a problem stemming from having an internal subpackage, and the remote service having trouble with that. 我的所有测试表明,这是一个问题源于内部子包,远程服务有问题。 The api package is not getting built from the local copy. api包不是从本地副本构建的。 fmt.Print works just fine from main.go , and moving GetIP from the api package to the main package lets fmt print just fine to stdout during web requests. fmt.Print工作得很好,从main.go和移动GetIPapi包到main包让fmt打印就好在Web请求到标准输出。

Basically, all changes made to the local api subpackage are getting ignored. 基本上,对本地api子包进行的所有更改都会被忽略。

The EB logs probably say something about which packages are being downloaded remotely; EB日志可能会说明远程下载哪些软件包; mine did. 我做了。

I'm not a Godep pro, so maybe a Godep pro can elaborate. 我不是Godep职业选手,所以也许Godep职业选手可以详细说明。 But FWIW, it seems like it might be related to this issue , tangentially. 但是FWIW似乎可能与这个问题有关。 It might also be a problem with the remote service not building with godep go build , but like I said, I'm not a Godep pro, so I'm unsure. 这也可能是远程服务没有使用godep go build ,但就像我说的那样,我不是Godep pro,所以我不确定。

It is possible you are running an older version of the app, when I try to build the container locally I get the following error: 您可能正在运行旧版本的应用程序,当我尝试在本地构建容器时,我收到以下错误:

➜ docker build .
# Executing 3 build triggers
Trigger 0, COPY . /go/src/app
Step 0 : COPY . /go/src/app
Trigger 1, RUN go-wrapper download
Step 0 : RUN go-wrapper download
 ---> Running in c1854666d13c
+ exec go get -v -d
github.com/julienschmidt/httprouter (download)
github.com/rdegges/ipify-api (download)
github.com/rs/cors (download)
Trigger 2, RUN go-wrapper install
Step 0 : RUN go-wrapper install
 ---> Running in 0bbdec1b99d7
+ exec go install -v
github.com/julienschmidt/httprouter
github.com/rdegges/ipify-api/models
github.com/rs/cors
github.com/rdegges/ipify-api/api
app
# app
./main.go:27: cannot use api.NotFound (type func(http.ResponseWriter, *http.Request)) as type http.Handler in assignment:
    func(http.ResponseWriter, *http.Request) does not implement http.Handler (missing ServeHTTP method)
./main.go:28: cannot use api.MethodNotAllowed (type func(http.ResponseWriter, *http.Request)) as type http.Handler in assignment:
    func(http.ResponseWriter, *http.Request) does not implement http.Handler (missing ServeHTTP method)
The command '/bin/sh -c go-wrapper install' returned a non-zero code: 2

Are there any errors in your event stream after you deploy? 部署后,您的事件流中是否有任何错误? "eb events" i believe. “eb events”我相信。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM