When running on CF, the app will expect to be bound to a Service Registry service instance with the name service-registry
. Create a service instance and push the app with the following commands:
$ cf cs p-service-registry standard service-registry
$ cf push eureka-sample
Once the app is running, it should register itself to Eureka so you can see it on the Eureka dashboard. Browse to the app’s route URL and use the links provided to change its status as registered to Eureka. Scaling the app to multiple instances to see multiple instances in the Eureka dashboard.
Push additional copies of the app with different names to see multiple apps registered to Eureka:
$ cf push another-sample
Apps that take a long time to shut down can be killed by Cloud Foundry before they get a chance to cancel their registration to Eureka. This will lead to instances being marked as DOWN
in Eureka with their leases never being cancelled. To simulate this condition, set the following environment variable on the app to cause a shutdown delay:
$ cf set-env eureka-sample SHUTDOWN_DELAY 15
$ cf restage eureka-sample
After the app has been staged with this environment variable, stopping the application (e.g. cf stop eureka-sample
) should result in DOWN
instances in Eureka.
Run the app locally with the following command:
$ java -jar build/libs/eureka-sample.jar
The app will expect a Eureka server to be running at the address http://localhost:8080
, and will authenticate to Eureka with the username admin
and the password admin
.