gpt4 book ai didi

go - 使用CloudSQL和Google App Engine在Gorm上部署Go后端时出现服务器错误500

转载 作者:行者123 更新时间:2023-12-01 22:22:34 27 4
gpt4 key购买 nike

我正在尝试在Google App Engine上部署Go后端,并连接到CloudSQL。部署魔术有效,但是当我尝试调用API时,状态为500:

Error: Server Error
The server encountered an error and could not complete your request.
Please try again in 30 seconds.

当运行 gcloud app logs tail -s default时,我有:
2020/06/07 21:39:26 server.go:52: dial unix /cloudsql/: connect: is a directory
    var dbURI string
dbURI = fmt.Sprintf("%s:%s@unix(/cloudsql/%s)/%s", dbUser, dbPwd, dbHost, dbName)

// Open database connection
db, err := gorm.Open(
"mysql",
dbURI,
)
if err != nil {
log.Fatal(err) <-- line 52
}

我的app.yaml设置正确(我认为..):
env_variables:
CLOUDSQL_CONNECTION_NAME: 'XXXXX:europe-west1:XXXXXX'
DB_USER: 'root'
DB_PASS: 'XXXXX'
DB_NAME: 'XXXXX'

任何帮助,将不胜感激 :)

最佳答案

我确实没有使用正确的ENV变量。谢谢您指出@Muffin返回页首

关于go - 使用CloudSQL和Google App Engine在Gorm上部署Go后端时出现服务器错误500,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62252167/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com