Question on gorouter running

23 views
Skip to first unread message

Hongliang Sun

unread,
Aug 20, 2013, 3:26:25 AM8/20/13
to vcap...@cloudfoundry.org
Hi,

I am new with gorouter. Recently I hope to repalce my old router with gorouter in Cloud Foundry v1. I installed go language and setup gorouter as github said like:

export GOPATH=~/go # or wherever
export PATH=$GOPATH/bin:$PATH
cd $GOPATH
mkdir -p src/github.com/cloudfoundry
(
  cd src/github.com/cloudfoundry
  git clone https://github.com/cloudfoundry/gorouter.git
)
go get -v ./src/github.com/cloudfoundry/gorouter/...

And I change the config file Go_path/src/github.com/cloudfoundry/gorouter/config/config.go with defaultNatsConfig's Host, User and Pass. In addition, I add a pidfile and log file path.

When I run the command "router", gorouter indeed connected to NATS in my Cloud Foundry, as in its log file does Cloud Foundry's information exist, like below:

{"timestamp":1376963647.551684141,"process_id":23275,"source":"router.global","log_level":"info","message":"Waiting 5s before listening...","data":null}
{"timestamp":1376963647.551996231,"process_id":23275,"source":"router.global","log_level":"debug","message":"router.register: Received message","data":{"message":{"host":"10.10.17.36","port":9022,"uris":["api.vcap.me"],"tags":{"component":"CloudController"},"app":"","private_instance_id":""}}}
{"timestamp":1376963647.552077055,"process_id":23275,"source":"router.global","log_level":"info","message":"Got router.register: &{10.10.17.36 9022 [api.vcap.me] map[component:CloudController]  }","data":null}
{"timestamp":1376963647.552713871,"process_id":23275,"source":"router.global","log_level":"debug","message":"router.register: Received message","data":{"message":{"host":"10.10.17.36","port":41610,"uris":["rails.vcap.me"],"tags":{"framework":"rails3","runtime":"ruby18"},"app":"91","private_instance_id":"59807548f765502bf90a32cc79e93ed5d3fdb9ce8213678d7bb9bfc8cee93402"}}}
{"timestamp":1376963647.552757978,"process_id":23275,"source":"router.global","log_level":"info","message":"Got router.register: &{10.10.17.36 41610 [rails.vcap.me] map[framework:rails3 runtime:ruby18] 91 59807548f765502bf90a32cc79e93ed5d3fdb9ce8213678d7bb9bfc8cee93402}","data":null}
{"timestamp":1376963647.552770853,"process_id":23275,"source":"router.global","log_level":"debug","message":"router.register: Received message","data":{"message":{"host":"10.10.17.36","port":58462,"uris":["smartcity.vcap.me"],"tags":{"framework":"spring","runtime":"java"},"app":"102","private_instance_id":"1765c35e2a34209defca867cf1b7e9e45ca5ee99aa995385a98da159db05ee59"}}}
{"timestamp":1376963647.552795887,"process_id":23275,"source":"router.global","log_level":"debug","message":"router.register: Received message","data":{"message":{"host":"10.10.17.36","port":37595,"uris":["hellospring.vcap.me"],"tags":{"framework":"spring","runtime":"java"},"app":"104","private_instance_id":"bbf8a272854f2338ddbf8f3558433a4493895bb4e072ff1477c18f7d3bb02e04"}}}
{"timestamp":1376963647.552886248,"process_id":23275,"source":"router.global","log_level":"info","message":"Got router.register: &{10.10.17.36 37595 [hellospring.vcap.me] map[framework:spring runtime:java] 104 bbf8a272854f2338ddbf8f3558433a4493895bb4e072ff1477c18f7d3bb02e04}","data":null}
{"timestamp":1376963647.552884817,"process_id":23275,"source":"router.global","log_level":"debug","message":"router.register: Received message","data":{"message":{"host":"10.10.17.36","port":21753,"uris":["env.vcap.me"],"tags":{"framework":"sinatra","runtime":"ruby18"},"app":"130","private_instance_id":"3ff7dc0f3d78f63a6b89feba0d0bbf38e32013ca08a8891621562dab59ddb75e"}}}
{"timestamp":1376963647.552812815,"process_id":23275,"source":"router.global","log_level":"debug","message":"router.register: Received message","data":{"message":{"host":"10.10.17.36","port":58270,"uris":["caldecott-1e051.vcap.me"],"tags":{"framework":"sinatra","runtime":"ruby18"},"app":"128","private_instance_id":"04397b77de253fe07460afa2c9c2339e6ae70e6158425bb3ee415e0975d1319b"}}}
{"timestamp":1376963647.552848816,"process_id":23275,"source":"router.global","log_level":"info","message":"Got router.register: &{10.10.17.36 58462 [smartcity.vcap.me] map[framework:spring runtime:java] 102 1765c35e2a34209defca867cf1b7e9e45ca5ee99aa995385a98da159db05ee59}","data":null}
{"timestamp":1376963647.552938223,"process_id":23275,"source":"router.global","log_level":"info","message":"Got router.register: &{10.10.17.36 21753 [env.vcap.me] map[framework:sinatra runtime:ruby18] 130 3ff7dc0f3d78f63a6b89feba0d0bbf38e32013ca08a8891621562dab59ddb75e}","data":null}
{"timestamp":1376963647.552958012,"process_id":23275,"source":"router.global","log_level":"info","message":"Got router.register: &{10.10.17.36 58270 [caldecott-1e051.vcap.me] map[framework:sinatra runtime:ruby18] 128 04397b77de253fe07460afa2c9c2339e6ae70e6158425bb3ee415e0975d1319b}","data":null}
{"timestamp":1376963652.551964045,"process_id":23275,"source":"router.global","log_level":"info","message":"Listening on [::]:8080","data":null}


While when the log stopped here, I find the gorouter process existed because i can not find a process with pid in pid file. Then What I can comfirm is that I cannot use vmc command to connect with Cloud Foundry.

And I check the source code of gorouter, finding that the code "router.NewRouter(c).Run()" in main.go must run incorrectly.
In the function run(), some codes are below:

     log.Infof("Listening on %s", listen.Addr())
    server := proxy.Server{Handler: router.proxy}

    go func() {
    
        err := server.Serve(listen)
        if err != nil {
            log.Fatalf("proxy.Serve: %s", err)
        }
    }()

It seems gorouter runs well at "log.Infof("Listening on %s", listen.Addr())", while when the router keeps itself alive to receive requests, the process exists unexpectedly.

Is the "go fuc()" used to handle concurrent request running incorrectly?
What is more, I still cannot figure out how it works with gorouter's log system. It uses steno, while in the log file I specified there is only info log, no warn log ,nor fatal log?
And is there any simple way to check wether gorouter is running except checking pid number of it?

Thanks in advance.

Best
Hongliang
Reply all
Reply to author
Forward
0 new messages