在OpenShift中无法运行Go二进制文件。

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

Go binary failed to run in openshift

问题

我在Go 1.2中开发了一个基本的Go REST Web服务。在我的本地Linux机器上,它按预期工作。但是,当我将生成的二进制文件通过scp命令复制到OpenShift上并尝试执行时,它立即终止而不监听端口。这是应用程序代码:https://gist.github.com/anidotnet/9720936

我尝试过在OpenShift服务器上编译的二进制文件和在我的本地Linux机器上编译的二进制文件,但结果是相同的。我尝试使用以下命令来执行它:

nohup ./app $

但它仍然终止。也没有任何恐慌日志。这里出了什么问题?我漏掉了什么吗?

英文:

I have developed a basic go rest webservice in go 1.2. It is working as expected in my local linux box. But when I scp'ed the generated binary to openshift and try to execute, it terminates instantaneously without listening to the port. Here is the application code : https://gist.github.com/anidotnet/9720936

I tried with both binary compiled at openshift server and binary compiled at my local linux box, but the result is same. Tried executing it using

> nohup ./app $

but it still terminates. No panic log is there as well. What is going wrong here? Am I missing something?

答案1

得分: 1

我不是Go专家,但是这里有一些你可以在你的程序中检查的事项:

确保你绑定到8080端口来提供你的应用程序服务
确保你绑定到你的OpenShift IP地址(而不是127.0.0.1、localhost或0.0.0.0,这些通常是默认值)

这是一个OpenShift Go Cartridge,你可以尝试一下(查看模板目录中的代码)以获取正确绑定的提示:https://github.com/smarterclayton/openshift-go-cart

你需要的环境变量可以通过ssh到你的gear并运行以下命令来找到:
env | grep IP
env | grep PORT

这些将根据你安装的Web Cartridge类型进行命名。

英文:

I am not a Go expert, but here are some things to check in your program:

Make sure that you are binding to port 8080 to serve your application from
Make sure that you are binding to your openshift ip address (not 127.0.0.1, localhost, or 0.0.0.0 which are usually the defaults)

Here is an OpenShift Go Cartridge that you can try (check out the code in the template directory) for hints on how to bind correctly: https://github.com/smarterclayton/openshift-go-cart

The environment variables you need can be found by sshing into your gear and running the following commands:
env | grep IP
env | grep PORT

These will be named according to the type of web cartridge you have installed.

huangapple
  • 本文由 发表于 2014年3月23日 21:28:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/22591536.html
匿名

发表评论

匿名网友

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

确定