将Go应用部署到Bluemix后,服务器无法启动。

huangapple go评论86阅读模式
英文:

Server Unable to Start after deploying go app to Bluemix

问题

我们无法将我们的示例Go Web程序部署到Bluemix。服务器试图启动,最后在没有任何错误的情况下崩溃。请告诉我是否需要修改任何文件。

在GitHub上查看我们的代码

构建日志:-

准备开始作业...
下载构建工件...
目标:https://api.ng.bluemix.net
使用清单文件/home/pipeline/4095d817-6887-4f7e-b317-c58c97c5afd7/manifest.yml

在组织Subhadeep /空间dev中创建应用程序JoinSplit-20170529103009108,作为subhadeep.bose@in.ibm.com...
好的

创建路由joinsplit-20170529103009108-anecdotal-menorah.mybluemix.net...
好的

将joinsplit-20170529103009108-anecdotal-menorah.mybluemix.net绑定到JoinSplit-20170529103009108...
好的

正在上传JoinSplit-20170529103009108...
从以下位置上传应用程序文件:/home/pipeline/4095d817-6887-4f7e-b317-c58c97c5afd7
上传165.2K,34个文件

上传完成
好的

在组织Subhadeep /空间dev中以subhadeep.bose@in.ibm.com的身份启动应用程序JoinSplit-20170529103009108...
创建容器
成功创建容器
下载应用程序包(437.8K)
-----> 下载go 1.8.3
-----> 检查Godeps/Godeps.json文件
-----> 安装godep v79
下载[https://buildpacks.cloudfoundry.org/dependencies/godep/godep-v79-linux-x64-9e37ce0f.tgz]
-----> 安装glide v0.12.3
下载[https://buildpacks.cloudfoundry.org/dependencies/glide/glide-v0.12.3-linux-x64-aa256363.tgz]
-----> 安装go 1.8.3
下载[https://buildpacks.cloudfoundry.org/dependencies/go/go1.8.3.linux-amd64-32ec5ac6.tar.gz]
-----> 运行go build finalize
[31;1m警告[0m vendor/目录不存在。
[31;1m警告[0m 安装软件包'.'(默认)
-----> 运行:go install -tags cloudfoundry -buildmode pie .
退出状态0
分期完成
上传droplet,构建工件缓存...
上传构建工件缓存...
上传droplet...
已上传构建工件缓存(194B)
已上传droplet(2.7M)
上传完成
成功销毁容器

1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个正在启动
1个实例中的0个正在运行,1个已崩溃
失败
重新启动应用程序时出错:启动失败

提示:使用'cf logs JoinSplit-20170529103009108 --recent'获取更多信息

完成:失败

英文:

We are unable to deploy our sample go web program to Bluemix. Server is trying to start and finally crashing without any error. Please let me know if any files needs modification.

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

答案1

得分: 3

你的代码正在监听硬编码的端口"8081",而不是Bluemix/Cloud Foundry环境提供的端口。在你的Main函数中尝试以下代码:

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

Your code is listening on the hardcoded port "8081", not on the one provided by the Bluemix/Cloud Foundry environment. Try something like the following in your Main function:

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

答案2

得分: 1

也许这个链接可以帮助你,里面有一些关于在Bluemix中使用Go的问答可供参考。

链接:https://developer.ibm.com/answers/questions/13591/about-using-go-with-bluemix.html

英文:

May be this link can help you out there are some Q&A are available on using go with Bluemix

https://developer.ibm.com/answers/questions/13591/about-using-go-with-bluemix.html

huangapple
  • 本文由 发表于 2017年5月29日 18:42:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/44240516.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定