scottfrederick / eureka-sample

Spring Cloud Netflix Eureka sample app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Spring Cloud Netflix Eureka sample app

Building

Build the app with the following command:

$ ./gradlew assemble

Running on Cloud Foundry

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

Simulating hard shutdown without canceling Eureka registration

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.

Running locally

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.

About

Spring Cloud Netflix Eureka sample app


Languages

Language:Java 90.1%Language:HTML 9.9%