dsa2c2255888 2015-08-13 15:30
浏览 35
已采纳

由于运行状况检查超时,BlueMix无法启动

I'm using Go to try create a simple 'hello world'-eque script using IBM's BlueMix. I've been able to use their hello world script which runs fine, however upon writing my own it fails.

I'm aware that you need to take the environment variable for the port, which is what I've done, however with this in place, the check is still unable to start the service.

package main

import (
    "io"
    "net/http"
    "log"
    "os"
    "fmt"
)

const (
    DEFAULT_PORT = "4001"
    DEFAULT_HOST = "localhost"
)

func HelloServer(w http.ResponseWriter, req *http.Request) {
    io.WriteString(w, "hello, world!
")
}

func main() {
    http.HandleFunc("/hello", HelloServer)

    var port string
    if port = os.Getenv("VCAP_APP_PORT"); len(port) == 0 {
        port = DEFAULT_PORT
    }

    var host string
    if host = os.Getenv("VCAP_APP_HOST"); len(host) == 0 {
        host = DEFAULT_HOST
    }


    log.Printf("Using host %v+
", host)
    log.Printf("Using port %v+
", port)
    fmt.Println("######" + port)

    err := http.ListenAndServe(host+":"+port, nil)
    if err != nil {
        log.Printf("ListenAndServe: ", err)
    }
}

Any help as to why this program is failing is greatly appreciated.

-- update --

The output of cf logs app --recent is:

2015-08-13T16:47:36.36+0100 [DEA/10]     OUT Removing crash for app with id ae803621-0b84-48d2-b3fd-6067053b40a6
2015-08-13T16:47:36.36+0100 [DEA/10]     OUT Stopping app instance (index 0) with guid ae803621-0b84-48d2-b3fd-6067053b40a6
2015-08-13T16:47:36.36+0100 [DEA/10]     OUT Stopped app instance (index 0) with guid ae803621-0b84-48d2-b3fd-6067053b40a6
2015-08-13T16:53:38.29+0100 [DEA/87]     OUT Starting app instance (index 0) with guid ae803621-0b84-48d2-b3fd-6067053b40a6
2015-08-13T16:54:02.13+0100 [DEA/87]     ERR Instance (index 0) failed to start accepting connections
2015-08-13T16:54:02.18+0100 [API/0]      OUT App instance exited with guid ae803621-0b84-48d2-b3fd-6067053b40a6 payload: {"cc_partition"=>"default", "droplet"=>"ae803621-0b84-48d2-b3fd-6067053b40a6", "version"=>"2ed88562-d12c-4391-ae8f-5fd8475cc350", "instance"=>"e4f99db81d194b1bb865a9e55f0a1d54", "index"=>0, "reason"=>"CRASHED", "exit_status"=>127, "exit_description"=>"failed to accept connections within health check timeout", "crash_timestamp"=>1439481242}
2015-08-13T16:54:02.21+0100 [API/10]     OUT App instance exited with guid ae803621-0b84-48d2-b3fd-6067053b40a6 payload: {"cc_partition"=>"default", "droplet"=>"ae803621-0b84-48d2-b3fd-6067053b40a6", "version"=>"2ed88562-d12c-4391-ae8f-5fd8475cc350", "instance"=>"e4f99db81d194b1bb865a9e55f0a1d54", "index"=>0, "reason"=>"CRASHED", "exit_status"=>127, "exit_description"=>"failed to accept connections within health check timeout", "crash_timestamp"=>1439481242}
  • 写回答

1条回答 默认 最新

  • du521521521 2015-08-14 14:50
    关注

    The above program I wrote is correct and runs as it should. The issue was that the procfile was not correctly set up. The procfile blueMix uses in its example Go program is web: gohelloworld.

    gohelloworld can be found in the godeps/Godeps.json file, as the ImportPath value. So when generating your godep file, the generated value from ImportPath is the value you should place in your procfile.

    In my case, it should have been: web: test.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行