PierreBesson/jhipster-microservices-docker

Find a way to make the registry complete its startup before launching microservices

Closed this issue · 5 comments

Currently, it is not possible to do this in docker-compose. You can only make the registry starts first with depends_on but it is not enough.
In any case it is not that important as it is working fine except for some errors on startup.

Different solutions, but it's tricky:

  1. add something like that in docker-compose file : command: sh -c "sleep 10 ; java -jar ..."

  2. add : command: run.sh

  • in your run.sh, you can do what you want. curl http://host:port until it's ok, then run your app
  • do a sleep

It has been asked on compose for a long time, but hard to know when the other service is completely started

I like 2).
Using curl on `http://registry/health' we should get this:

{
    "status": "UP",
    "configServer": {
        "status": "UP",
        "repositories": [{
            "sources": ["file:central-config/application.yml"],
            "name": "app",
            "profiles": ["default"],
            "label": null
        }]
    },
    "discoveryComposite": {
        "description": "Spring Cloud Eureka Discovery Client",
        "status": "UP",
        "discoveryClient": {
            "description": "Spring Cloud Eureka Discovery Client",
            "status": "UP",
            "services": []
        },
        "eureka": {
            "description": "Remote status from Eureka server",
            "status": "UNKNOWN",
            "applications": {}
        }
    },
    "diskSpace": {
        "status": "UP",
        "total": 229230825472,
        "free": 175993442304,
        "threshold": 10485760
    }
}

Then we check for status==UP and configServer.status==UP in run.sh and loop every seconds, this should be enough right ?
If it works, do you think we should also add this to the registry.yml in the main generator or it is not needed ?

I tried to bring answers, because "docker-compose" can't do it for the moment, and I'm not sure it will be done in the future.
In my opinion, it begins to become too tricky and the user can simply :

  1. launch 1st docker-compose
  2. wait little, and launch the 2nd
    But it's just my opinion :-)

I agree with you lets not put too much magic and instruct users to start the stack in the correct order.
Eventually this can be done with a script that uses curl /health to wait until everything is in order.

  • docker-compose up jhipster-registry
  • docker-compose up elk-elasticsearch elk-logstash elk-kibana
  • start apps : docker-compose up gateway app1 app2

This is now solved in the main generator by using retries for the config server config