go - 将 go 应用程序部署到 Bluemix 后服务器无法启动

标签 go ibm-cloud ibm-cloud-tools devops-services

我们无法将样本 go web 程序部署到 Bluemix。服务器正在尝试启动并最终在没有任何错误的情况下崩溃。如果有任何文件需要修改,请告诉我。

View Our Code In GitHub

Build Log:-

Preparing to start the job...
Downloading build artifacts...
Target: https://api.ng.bluemix.net
Using manifest file /home/pipeline/4095d817-6887-4f7e-b317-c58c97c5afd7/manifest.yml

Creating app JoinSplit-20170529103009108 in org Subhadeep / space dev as subhadeep.bose@in.ibm.com...
OK

Creating route joinsplit-20170529103009108-anecdotal-menorah.mybluemix.net...
OK

Binding joinsplit-20170529103009108-anecdotal-menorah.mybluemix.net to JoinSplit-20170529103009108...
OK

Uploading JoinSplit-20170529103009108...
Uploading app files from: /home/pipeline/4095d817-6887-4f7e-b317-c58c97c5afd7
Uploading 165.2K, 34 files


Done uploading
OK

Starting app JoinSplit-20170529103009108 in org Subhadeep / space dev as subhadeep.bose@in.ibm.com...
Creating container
Successfully created container
Downloaded app package (437.8K)
-----> Download go 1.8.3
-----> Checking Godeps/Godeps.json file
-----> Installing godep v79
       Download [https://buildpacks.cloudfoundry.org/dependencies/godep/godep-v79-linux-x64-9e37ce0f.tgz]
-----> Installing glide v0.12.3
       Download [https://buildpacks.cloudfoundry.org/dependencies/glide/glide-v0.12.3-linux-x64-aa256363.tgz]
-----> Installing go 1.8.3
       Download [https://buildpacks.cloudfoundry.org/dependencies/go/go1.8.3.linux-amd64-32ec5ac6.tar.gz]
-----> Running go build finalize
       [31;1m**WARNING**[0m vendor/ directory does not exist.
       [31;1m**WARNING**[0m Installing package '.' (default)
-----> Running: go install -tags cloudfoundry -buildmode pie .
Exit status 0
Staging complete
Uploading droplet, build artifacts cache...
Uploading build artifacts cache...
Uploading droplet...
Uploaded build artifacts cache (194B)
Uploaded droplet (2.7M)
Uploading complete
Successfully destroyed container

0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 crashed
FAILED
Error restarting application: Start unsuccessful

TIP: use 'cf logs JoinSplit-20170529103009108 --recent' for more information

Finished: FAILED

最佳答案

您的代码正在监听硬编码端口“8081”,而不是 Bluemix/Cloud Foundry 环境提供的端口。在您的 Main 函数中尝试类似以下内容:

err := http.ListenAndServe(":"+os.Getenv("PORT"), nil)

关于go - 将 go 应用程序部署到 Bluemix 后服务器无法启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44240516/

相关文章:

html - 如何将 html 数据移动到 Golang 中的结构

go - Go 有 lambda 表达式或类似的东西吗?

database - Golang 测试,调用数据库 Prepare 应该会失败,但实际上并没有

security - 通过防火墙获取 BlueMix 应用程序

docker - IBM Container-su:无法创建子进程:资源暂时不可用

eclipse - 无法在 Eclipse (Bluemix) 上部署应用程序

go - 除了可移植性和安全性原因之外,为什么有人想通过 WebAssembly 在 Web 浏览器中运行他们现有的 go/rust/c++ 应用程序?

ibm-cloud - IBM hyperledger chainCode 状态中的字节大小限制是多少?

java - 无法通过 docker java 运行时从 ibm 云函数操作获取结果 json

java - 使用 Java Buildpack 将工件上传到 bluemix 时出现错误 "Authentication error. Please log back to authenticate"