Hallo,
I have tomcat running as docker service in a swarm. When the service starts it loads lots of data into memory, which can take depending on the amount of data between 10 and 30 minutes.
My problem is when I update the service (order:start-first) the old container is stopped before the new container has intialized its data and is so not ready to use.
A promising approach seemed to me the health check configuration in my docker-compose:
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/areyouready"]
interval: 10s
timeout: 10s
retries: 30
The healthcheck works fine but the old service also shuts down while the test returns 1 (not healthy) for the new service.
I also tried to handle the SIGTERM in my application: The running service gets the sigterm and checks whether it should already stop depending on the state of the new service:
Runtime.getRuntime().addShutdownHook(new Thread()
{
@Override
public void run()
{
// via db access determine the state of the new started containers, but I don't know
// how to prevent my tomcat from stopping here
}
}
Besides that I didn’t manage to prevent my tomcat from stopping it just didn’t seem to be the right way.
My desired solution would be to configure something like this:
update_config:
order: start-first
a-kind-of-stop-condition: ["CMD", "curl", "-f", "http://localhost:8080/areyouready"]
the condition request should then go to the new created container and if it succeeds the old may be stopped.
What I want to avoid is working with delay-settings, because I want to avoid running the old version and the new version in parallel.
It would be great if you could point me into the right direction.
Kind regards, Sebastian