亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何將 Google App Engine (Flex) Go 應用連接到 Google Cloud

如何將 Google App Engine (Flex) Go 應用連接到 Google Cloud

Go
慕哥9229398 2023-07-10 16:30:05
我正在用 Go 構建一個應用程序,并使用 Google App Engine 進行部署。我已經在 Google Cloud 上設置了一個 PostgreSQL 實例,啟用了 API,并使用本地計算機上的 SQL 代理(從本地 PSequel 客戶端和我的應用程序)成功連接到它。gcloud app deploy但是,當我這樣做時,我收到此錯誤:ERROR: (gcloud.app.deploy) Error Response: [9] Application startup error:panic: dial unix /cloudsql/sapling:europe-west1:sapling/.s.PGSQL.5432: connect: no such file or directory我嘗試將 Postgres 實例從版本 11 Beta 降級到 9.6。還嘗試過使用這個驅動程序https://github.com/broady/gae-postgres,這看起來很有希望,但我無法在 Flex 環境中工作。應用程序.yamlruntime: go#Here we select the AppEngine Flex environment which performs a lot of the backend preparation for us including the ability to scale give the demandenv: flexenv_variables:  POSTGRES_CONNECTION: "user=postgres password=thisisntmypwd dbname=postgres host=/cloudsql/sapling:europe-west1:sapling"manual_scaling:  instances: 1#Select resource sizeresources:  cpu: 1  memory_gb: 0.5  disk_size_gb: 10beta_settings:  cloud_sql_instances: sapling:europe-west1:sapling=tcp:5432配置/db.gopackage configimport (    "database/sql"    "fmt"    _ "github.com/lib/pq"    "os")var Db *sql.DB//Set up connection to the databasefunc init() {    var err error    datastoreName := os.Getenv("POSTGRES_CONNECTION")    Db, err = sql.Open(        "postgres",        datastoreName,        )    if err != nil {        panic(err)    }    err = Db.Ping()    if err != nil {        panic(err)    }    fmt.Println("Connected to database")}
查看完整描述

1 回答

?
婷婷同學_

TA貢獻1844條經驗 獲得超8個贊

我在我的測試環境中復制了這個問題,發現您收到的錯誤是由于 beta_settings 指定了端口。我在最后嘗試了它=tcp:5432,它給了我同樣的錯誤,然后我在沒有它的情況下嘗試它,它部署沒有任何問題。



查看完整回答
反對 回復 2023-07-10
  • 1 回答
  • 0 關注
  • 151 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號