国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

目錄
在 Heroku 上部署 golang 應(yīng)用程序:構(gòu)建成功,但應(yīng)用程序顯示錯誤
問題
代碼和日志
解決方案
首頁 后端開發(fā) Golang 盡管構(gòu)建成功,為什么我在 Heroku 上的 Go 應(yīng)用程序部署成功,但應(yīng)用程序卻顯示'應(yīng)用程序錯誤”?

盡管構(gòu)建成功,為什么我在 Heroku 上的 Go 應(yīng)用程序部署成功,但應(yīng)用程序卻顯示'應(yīng)用程序錯誤”?

Dec 04, 2024 am 04:15 AM

Why does my Go app deployment on Heroku succeed, yet the application displays an

在 Heroku 上部署 golang 應(yīng)用程序:構(gòu)建成功,但應(yīng)用程序顯示錯誤

問題

使用 godep 支持在 Heroku 上部署 Go 應(yīng)用程序時,構(gòu)建成功,但訪問端點會導(dǎo)致“應(yīng)用程序錯誤”。

代碼和日志

應(yīng)用中使用了以下代碼:

import (
    "log"
    "fmt"
    "net/http"
    "os"

    "github.com/gorilla/mux"
    "github.com/gorilla/context"

    "gopkg.in/paytm/grace.v1"
)

func main() {
    log.Println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ CHIT STARTED $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
    log.Println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")

    muxRouter := mux.NewRouter()

    muxRouter.HandleFunc("/", Articles)
    http.Handle("/", muxRouter)

    port := os.Getenv("PORT")
    if port == "" {
        port = "9000" // Default port if not specified
    }

    err := grace.Serve(":" + port, context.ClearHandler(http.DefaultServeMux))
    if err != nil {
        log.Println("[ERROR GRACEFUL]", err)
        os.Exit(1)
    }

    os.Exit(0)
}

func Articles(w http.ResponseWriter, r *http.Request) {
    // vars := mux.Vars(r)
    w.WriteHeader(http.StatusOK)
    fmt.Fprintf(w, "Hello")
    // r.Close = true
    // w.Header().Set("Content-Type", "application/json")
    // w.Header().Set("Access-Control-Allow-Origin", "*")

    /*if r.Method == "OPTIONS" {
        w.WriteHeader(http.StatusOK)
        return
    }

    if err := fn(w, r); err != nil {
        log.Println(err)
        apiObject := ConstructAPIError(http.StatusInternalServerError, ErrGeneral, SysMsgErrGeneral, MsgErrGeneral)
        SendAPIObject(w, apiObject)
        return
    }*/
}

部署時的Heroku日志如下:

-----> Go app detected
-----> Fetching jq... done
-----> Fetching stdlib.sh.v8... done
-----> Checking Godeps/Godeps.json file.
-----> New Go Version, clearing old cache
-----> Installing go1.12.6
-----> Fetching go1.12.6.linux-amd64.tar.gz... done
-----> Running: go install -v -tags heroku ./... 
bitbucket.org/michaelchandrag/chit/pkg
bitbucket.org/michaelchandrag/chit/vendor/github.com/gorilla/context
bitbucket.org/michaelchandrag/chit/vendor/github.com/gorilla/mux
bitbucket.org/michaelchandrag/chit/vendor/gopkg.in/tylerb/graceful.v1
bitbucket.org/michaelchandrag/chit/vendor/gopkg.in/paytm/grace.v1
bitbucket.org/michaelchandrag/chit/pkg/util
bitbucket.org/michaelchandrag/chit

       Installed the following binaries:
            ./bin/chit
-----> Discovering process types
       Procfile declares types -> web
-----> Compressing...
       Done: 7.5M
-----> Launching...
       Released v3
       https://michaelchandrag-project.herokuapp.com/ deployed to Heroku

應(yīng)用訪問前后的日志端點是:

2:47.954106+00:00 heroku[web.1]: Starting process with command `chit`
2019-07-08T05:02:49.413453+00:00 app[web.1]: 2019/07/08 05:02:49 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ CHIT STARTED $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
2019-07-08T05:02:49.413476+00:00 app[web.1]: 2019/07/08 05:02:49 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
2019-07-08T05:02:49.413647+00:00 app[web.1]: 2019/07/08 05:02:49 starting serve on  :9000
2019-07-08T05:03:48.131507+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2019-07-08T05:03:48.131595+00:00 heroku[web.1]: Stopping process with SIGKILL
2019-07-08T05:03:48.214979+00:00 heroku[web.1]: State changed from starting to crashed
2019-07-08T05:03:48.193205+00:00 heroku[web.1]: Process exited with status 137
2019-07-08T10:38:59.721224+00:00 heroku[web.1]: State changed from crashed to starting
2019-07-08T10:39:00.359017+00:00 heroku[web.1]: Starting process with command `chit`
2019-07-08T10:39:02.232435+00:00 app[web.1]: 2019/07/08 10:39:02 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ CHIT STARTED $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
2019-07-08T10:39:02.232458+00:00 app[web.1]: 2019/07/08 10:39:02 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
2019-07-08T10:39:02.232583+00:00 app[web.1]: 2019/07/08 10:39:02 starting serve on  :9000
2019-07-08T10:40:00.462841+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2019-07-08T10:40:00.462974+00:00 heroku[web.1]: Stopping process with SIGKILL
2019-07-08T10:40:00.555959+00:00 heroku[web.1]: Process exited with status 137
2019-07-08T10:40:00.573427+00:00 heroku[web.1]: State changed from starting to crashed

解決方案

應(yīng)用程序啟動但因為它沒有綁定到指定的端口而被殺死。從 Heroku 日志消息中可以明顯看出:

2019-07-08T05:03:48.131507+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

要解決此問題,網(wǎng)絡(luò)服務(wù)器必須綁定到 PORT 環(huán)境變量指定的端口。在 Heroku 上,HTTP 服務(wù)器通過 Heroku 網(wǎng)關(guān)在默認(rèn) HTTP 和 HTTPS 端口上公開可用。

因此,應(yīng)用程序應(yīng)綁定到指定端口而不是 :9000。

以上是盡管構(gòu)建成功,為什么我在 Heroku 上的 Go 應(yīng)用程序部署成功,但應(yīng)用程序卻顯示'應(yīng)用程序錯誤”?的詳細(xì)內(nèi)容。更多信息請關(guān)注PHP中文網(wǎng)其他相關(guān)文章!

本站聲明
本文內(nèi)容由網(wǎng)友自發(fā)貢獻(xiàn),版權(quán)歸原作者所有,本站不承擔(dān)相應(yīng)法律責(zé)任。如您發(fā)現(xiàn)有涉嫌抄襲侵權(quán)的內(nèi)容,請聯(lián)系admin@php.cn

熱AI工具

Undress AI Tool

Undress AI Tool

免費脫衣服圖片

Undresser.AI Undress

Undresser.AI Undress

人工智能驅(qū)動的應(yīng)用程序,用于創(chuàng)建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用于從照片中去除衣服的在線人工智能工具。

Clothoff.io

Clothoff.io

AI脫衣機(jī)

Video Face Swap

Video Face Swap

使用我們完全免費的人工智能換臉工具輕松在任何視頻中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的代碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

功能強(qiáng)大的PHP集成開發(fā)環(huán)境

Dreamweaver CS6

Dreamweaver CS6

視覺化網(wǎng)頁開發(fā)工具

SublimeText3 Mac版

SublimeText3 Mac版

神級代碼編輯軟件(SublimeText3)

如何在GO中的結(jié)構(gòu)實例上調(diào)用方法? 如何在GO中的結(jié)構(gòu)實例上調(diào)用方法? Jun 24, 2025 pm 03:17 PM

在Go語言中,調(diào)用結(jié)構(gòu)體方法需先定義結(jié)構(gòu)體和綁定接收者的方法,使用點號訪問。定義結(jié)構(gòu)體Rectangle后,可通過值接收者或指針接收者聲明方法;1.使用值接收者如func(rRectangle)Area()int,通過rect.Area()直接調(diào)用;2.若需修改結(jié)構(gòu)體,應(yīng)使用指針接收者如func(r*Rectangle)SetWidth(...),Go會自動處理指針與值的轉(zhuǎn)換;3.嵌入結(jié)構(gòu)體時,內(nèi)嵌結(jié)構(gòu)體的方法會被提升,可直接通過外層結(jié)構(gòu)體調(diào)用;4.Go無需強(qiáng)制使用getter/setter,字

將Golang服務(wù)與現(xiàn)有Python基礎(chǔ)架構(gòu)集成的策略 將Golang服務(wù)與現(xiàn)有Python基礎(chǔ)架構(gòu)集成的策略 Jul 02, 2025 pm 04:39 PM

TOIntegrategolangServicesWithExistingPypythoninFrasture,userestapisorgrpcForinter-serviceCommunication,允許GoandGoandPyThonAppStoStoInteractSeamlessSeamLlyThroughlyThroughStandArdArdAdrotized Protoccols.1.usererestapis(ViaFrameWorkslikeSlikeSlikeGiningOandFlaskInpyThon)Orgrococo(wirs Propococo)

了解Web API的Golang和Python之間的性能差異 了解Web API的Golang和Python之間的性能差異 Jul 03, 2025 am 02:40 AM

Golangofferssuperiorperformance,nativeconcurrencyviagoroutines,andefficientresourceusage,makingitidealforhigh-traffic,low-latencyAPIs;2.Python,whileslowerduetointerpretationandtheGIL,provideseasierdevelopment,arichecosystem,andisbettersuitedforI/O-bo

是Golang前端還是后端 是Golang前端還是后端 Jul 08, 2025 am 01:44 AM

Golang主要用于后端開發(fā),但也能在前端領(lǐng)域間接發(fā)揮作用。其設(shè)計目標(biāo)聚焦高性能、并發(fā)處理和系統(tǒng)級編程,適合構(gòu)建API服務(wù)器、微服務(wù)、分布式系統(tǒng)、數(shù)據(jù)庫操作及CLI工具等后端應(yīng)用。雖然Golang不是網(wǎng)頁前端的主流語言,但可通過GopherJS編譯成JavaScript、通過TinyGo運行于WebAssembly,或搭配模板引擎生成HTML頁面來參與前端開發(fā)。然而,現(xiàn)代前端開發(fā)仍需依賴JavaScript/TypeScript及其生態(tài)。因此,Golang更適合以高性能后端為核心的技術(shù)棧選擇。

如何完全,干凈地從我的系統(tǒng)中卸載Golang? 如何完全,干凈地從我的系統(tǒng)中卸載Golang? Jun 30, 2025 am 01:58 AM

TocompletelyuninstallGolang,firstdeterminehowitwasinstalled(packagemanager,binary,source,etc.),thenremoveGobinariesanddirectories,cleanupenvironmentvariables,anddeleterelatedtoolsandcaches.Beginbycheckinginstallationmethod:commonmethodsincludepackage

如何使用頻道在Golang的Goroutines之間進(jìn)行通信? 如何使用頻道在Golang的Goroutines之間進(jìn)行通信? Jun 26, 2025 pm 12:08 PM

Go語言中channel用于goroutine間通信與同步。聲明使用make函數(shù),如ch:=make(chanstring),發(fā)送用ch

如何在Golang中使用Select語句進(jìn)行非阻滯渠道操作和超時? 如何在Golang中使用Select語句進(jìn)行非阻滯渠道操作和超時? Jun 26, 2025 pm 01:08 PM

在Go中,使用select語句可以有效處理非阻塞通道操作和實現(xiàn)超時機(jī)制。通過default分支實現(xiàn)非阻塞接收或發(fā)送操作,如1.非阻塞接收:若有值則接收并打印,否則立即執(zhí)行default分支;2.非阻塞發(fā)送:若通道無接收者則跳過發(fā)送。此外,結(jié)合time.After可實現(xiàn)超時控制,例如等待結(jié)果或2秒后超時返回。還可組合非阻塞與超時行為,先嘗試立即獲取值,失敗后再短暫等待,提升程序并發(fā)響應(yīng)能力。

如何使用自定義字段名稱將golang結(jié)構(gòu)元載到JSON? 如何使用自定義字段名稱將golang結(jié)構(gòu)元載到JSON? Jun 30, 2025 am 01:59 AM

在Go中,若希望結(jié)構(gòu)體字段在轉(zhuǎn)換為JSON時使用自定義字段名,可通過結(jié)構(gòu)體字段的json標(biāo)簽實現(xiàn)。1.使用json:"custom_name"標(biāo)簽指定字段在JSON中的鍵名,如Namestringjson:"username""會使Name字段輸出為"username";2.添加,omitempty可控制字段為空值時省略輸出,例如Emailstringjson:"email,omitempty""

See all articles