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

这是一个深入的问题,所以我会尽力解释它。

我在Go中构build了一个小的API服务,我试图使用相对较新的AWS Elastic Beanstalk Docker 支持部署到AWS。

这就是我所做的(代码全部是开源的,所以如果你愿意的话,你可以按照下面的步骤):

$ 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 

这将使用弹性beanstalk创build一个新的应用程序(与docker),并部署它。

如果我然后运行eb open我的web应用程序,我会看到我的公共IP地址(这是正确的行为),所以我知道我的应用程序正在运行/function。

现在,在我的源代码中,我有几行debugging输出:

 fmt.Println("WOOOOOOOOOOOO") 

上面的语句只是打印“WOO …”到控制台。 每次发出新的请求时都会执行此操作。

不幸的是,当我运行eb logs来查看我的实例日志时,这个debugging行从来没有出现 – 我不明白为什么。

我试过打印到STDERR,打印到STDOUT等 – 但我绝对不能得到任何输出。

我search了互联网寻找解决scheme,但还没有find任何解决scheme。

我认为import "github.com/rdegges/ipify-api/api"是从Github上的副本构build的,而不是从本地副本中构build的。 最近提交的api包没有多余的fmt语句。 此外, main.golog语句main.go工作, fmt.Fprintf已经在api包中。 尝试validationapi包是从你认为的源代码构build的。

编辑6/1/2015:

我所有的testing都表明这是一个内部分包产生的问题,远程服务也遇到了麻烦。 api包不是从本地拷贝构build的。 fmt.Print工作得很好,并且将GetIPapi包移动到main包,可以让fmt在web请求期间正确输出stdout。

基本上,对本地api子包进行的所有更改都被忽略了。

EB日志可能会提到哪些软件包正在远程下载; 我做到了。

我不是Godep专家,所以也许Godep专家可以详细说明。 但是FWIW,似乎可能与这个问题有关 ,切线。 这也可能是一个远程服务不与godep go build ,但正如我所说,我不是一个Godep的专业人士,所以我不确定。

当我尝试在本地构build容器时,可能会运行应用程序的旧版本,但出现以下错误:

 ➜ 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 

部署后,您的事件stream中是否有错误? 我相信“eb事件”。