Reputation: 33854
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.
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.
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.
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. 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.
I've tried printing to STDERR, printing to STDOUT, etc. – but I'm absolutely unable to get any output.
I've scoured the internet looking for solutions, but have yet to find any.
Upvotes: 13
Views: 801
Reputation: 80
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.
Upvotes: 0
Reputation: 152
I think import "github.com/rdegges/ipify-api/api"
is being built from the copy on Github, not from the local copy. The most recent commit of the api
package doesn't have the extraneous fmt
statements. Also, the log
statement in main.go
works fine, as does the fmt.Fprintf
already in the api
package. Try to verify the api
package is getting built from the source you think it is.
EDIT 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. 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.
Basically, all changes made to the local api
subpackage are getting ignored.
The EB logs probably say something about which packages are being downloaded remotely; mine did.
I'm not a Godep pro, so maybe a Godep pro can elaborate. But FWIW, it seems like it might be related to this issue, tangentially. 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.
Upvotes: 1