spring-projects / spring-lifecycle-smoke-tests

20 stars 18 forks source link

Add support for Config Server client #49

Open marcoberri opened 8 months ago

marcoberri commented 8 months ago

Hi,

it be possible to have an example of connection to the config server client by a micro service in spring boot cloud?

tnx

We try with:

docker run -it --network=base-network -v /home/cicduser/workspace/tmp:/opt/crac-files --cap-add=CHECKPOINT_RESTORE --cap-add=SYS_PTRACE --privileged --expose 8069 --rm --name ms-crac nexus.xxxx.com/microservice-architecture/ms-crac:1.0.9-release

docker commit --change='ENTRYPOINT ["/opt/app/entrypoint.sh"]' $(docker ps -qf "name=ms-crac") ms-crac-checkpoint:checkpoint

docker run --privileged --cap-add CHECKPOINT_RESTORE --cap-add SYS_ADMIN --rm -p 8069:8069 -e SPRING_PROFILES_ACTIVE=dev -e JAVA_TOOL_OPTIONS="-Dspring.cloud.config.enabled=true" -v /home/cicduser/workspace/tmp:/opt/crac-files --name ms-crac-checkpoint ms-crac-checkpoint:checkpoint

entrypoint.sh

CRAC_FILES_DIR=`eval echo ${CRAC_FILES_DIR}`
mkdir -p $CRAC_FILES_DIR

if [ -z "$(ls -A $CRAC_FILES_DIR)" ]; then
 echo 128 > /proc/sys/kernel/ns_last_pid; java -Dspring.cloud.config.enabled=false -Dspring.profiles.active=dev -Dspring.context.checkpoint=onRefresh -Dmanagement.endpoint.health.probes.add-additional-paths="true" -Dmanagement.health.probes.enabled="true" -XX:CRaCCheckpointTo=$CRAC_FILES_DIR -jar /opt/app/ms.jar&
    sleep 5
    jcmd /opt/app/ms.jar JDK.checkpoint
else
  java -Dmanagement.endpoint.health.probes.add-additional-paths="true" -Dmanagement.health.probes.enabled="true" -XX:CRaCRestoreFrom=$CRAC_FILES_DIR&
  PID=$!
  trap "kill $PID" SIGINT SIGTERM
  wait $PID
fi

configserver.properties

spring.config.import=optional:configserver:http://server-name:8061/config-server/

when i try to restore with different profiles (spring.profiles.active), the ms is not reconnect to config server.

marcoberri commented 8 months ago

close as duplicate -> https://github.com/spring-projects/spring-checkpoint-restore-smoke-tests/issues/50