Skip to content

dieucao/fortune-teller-ruby

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Fortune Teller Demo (Ruby)

A rewrite of the Spring Fortune Teller demo in Ruby, made of two components, the UI and the Fortune Service.

Running the demo on Cloud Foundry

Requires cf networking, polyglot service discovery enabled.

Optionally use the experimental zdt restart and push with cflinuxfs3 stack and ruby buildpack

  1. Push both apps
cf push fortune-teller-ui -b ruby_buildpack -m 100M -i 3 
cf push fortune-teller-server -b ruby_buildpack --no-route -m 100M -i 2
  1. Access the UI, for example on bosh-lite, http://fortune-teller-ui.bosh-lite.com/, and enable auto-refresh

  2. Map an internal route to the fortune-teller-server

cf map-route fortune-teller-server apps.internal --hostname fortune-teller-server
  1. Create a service and, bind it to fortune-teller-ui
cf cups fortune-server -p '{"url":"http://fortune-teller-server.apps.internal:8080"}'
cf bs fortune-teller-ui fortune-server
  1. Restart your app

If you don't have capi deployments enabled

cf restart fortune-teller-ui

If you do have the very experimental capi deployments enabled

cf v3-zdt-restart fortune-teller-ui
  1. Add app to app network policy
cf add-network-policy fortune-teller-ui --destination-app fortune-teller-server
  1. Bonus! If you have cflinuxfs3 stack and ruby buildpack available, do a zero down time update of dependencies of the fortune-teller-ui (Also requires the very experimental capi deployments feature)
cf v3-zdt-push fortune-teller-ui -s cflinuxfs3 --wait-for-deploy-complete

Running the demo locally

Both applications are simple Sinatra applications using the Rack.

  1. Start the Fortune Service
cd fortune-teller-server
rackup -p 9293
  1. In a sercond terminal, start the UI
cd fortune-teller-ui
rackup
  1. Access the UI at http://localhost:9292

Connecting the UI to the Fortune Service

By default, the UI will look for the Fortune Service at http://localhost:9293, however this can be changed when deployed to Cloud Foundry using a User-Provided Service and binding it to the deployed version of the UI.

cf create-user-provided-service fortune-server -p '{"url":"http://fortune-server.cfapps.io"}'

cf bind-service fortune-ui fortune-server

About

A rewrite of the Spring Fortune Teller demo in Ruby

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 39.1%
  • HTML 29.0%
  • CSS 21.4%
  • JavaScript 10.5%