igrigorik / ga-beacon

Google Analytics collector-as-a-service (using GA measurement protocol).
MIT License
3.54k stars 358 forks source link

Not able to deploy with Go 1.12+ #71

Closed cantrellryan closed 4 years ago

cantrellryan commented 4 years ago

We've been running this app for the last couple of years with great success. I saw the recent updates to the project to support running on Go 1.12+ but am unable to to deploy it successfully.

After doing some digging it appears that the issue is that the package "appengine" is deprecated with Go 1.12. Is there a way to deploy with 1.12 or 1.13 or does that require a re-write of the main app?

hwdsl2 commented 4 years ago

There are a few other changes needed for deploying with Go 1.12+, such as the required "main" package (unable to deploy without "package main") and changes in dependency management. See [1]. A rewrite of at least part of the application will likely be needed.

[1] https://cloud.google.com/appengine/docs/standard/go/go-differences

cantrellryan commented 4 years ago

Yeah, saw that and was able to get past that by renaming the package. But the next steps were beyond my skillset unfortunately.

aravind-j commented 4 years ago

I have added main.go as suggested in https://cloud.google.com/appengine/docs/standard/go/go-differences#migrating-appengine-sdk. But now with gcolud app deploy it shows the root of you app needs to be package "main" (currently "beacon").

alokc83 commented 4 years ago

@aravind-j in your go file, you need to add package main also, add this method after init

func main() {
        http.HandleFunc("/", indexHandler)

        port := os.Getenv("PORT")
        if port == "" {
                port = "8080"
                log.Printf("Defaulting to port %s", port)
        }

        log.Printf("Listening on port %s", port)
        if err := http.ListenAndServe(":"+port, nil); err != nil {
                log.Fatal(err)
        }
}

but it is failing on appengine import I have no idea how to fix that

alokc83 commented 4 years ago

@igrigorik I know you are busy. Do you mind adding new deployment instructions

igrigorik commented 4 years ago

Resolved via https://github.com/igrigorik/ga-beacon/commit/ebbc061431ac203109eb058be300803302bbc72b