Giter Site home page Giter Site logo

devopshw4's Introduction

#HW 4

##Prerequisites

You'll need the following:

  • Redis - You can get it here, you'll want it installed globally. If you are on OSX and have homebrew installed the easiest way is the following command:

brew install redis

  • npm/nodejs - You can get it here. Again, with homebrew:

brew install node

##Usage

This setup was designed to be completely self contained. Everything is glued together with one main bash script called install.sh. Basic function when install.sh runs is as follows:

  • It generates this folder structure:
  • root
    • App
    • deploy
      • blue.git
      • green.git
      • blue-www
      • green-www
  • It downloads a server setup into App and sets up blue.git and green.git as git repos.
  • It generates a post-recieve hook based on where the repo is downloaded to in both blue.git and green.git.
  • It runs npm install in the App folder and in the root folder
  • It generates two git remotes in the App folder:
    • blue
    • green
  • It runs git add -A in App
  • Finally it runs git commit -m "first commit" in App

At this point the entire structure is completely set up. A screenshot of the command line output is shown below:

install.sh

Going to the App folder and running:

git push green master

Pushes to green-www and runs a command to run redis-server on port 6379.

A screenshot is below:

greenpush

git push blue master

Pushes to blue-www and runs a command to run redis-server on port 6380.

A screenshot is below:

bluepush

Running

node infrastructure.js

brings up the infrastructure proxy setup.

A screenshot is below:

infrastructure

You'll see when running that going here brings up the setup shown below:

firstcommand

Running without mirroring is as simple as setting mirrorFlag boolean on line 21 of infrastructure.js to false.

Going to the switch route here results in a switch between the two deployed nodes, as shown below:

switch

The migration effect can be displayed by running the following set of commands:

cd App

curl -F "image=@./img/morning.jpg" localhost:8080/upload

Then visit the switch route here as shown below:

switchmigrate1

Then visit the meow route here with screenshot below:

switchmigrate2

This is accomplished without destroying the data on the original node. Put another way: on another switch back to the original node the cat picture will still be in that node's redis instance, as shown in the screenshot below:

switchmigrate3

The final bit of functionality here is actual mirroring between the two redis instances on uploading. Again switching back the mirrorFlag boolean on line 21 of infrastructure.js to true the following behavior can be seen:

Run the same uploading commands as before:

cd App

curl -F "image=@./img/morning.jpg" localhost:8080/upload

Then if we visit the meow route here with screenshot below:

mirror1

I'll note that at this point the cat picture has been popped out of the redis instance for port 9090 and will not be migrated by the earlier behavior. You can see that below:

emptyredis

Now upon visiting the switch route here, and visiting the meow route here, you can see in the image below that the cat picture was actually successfully mirrored to the other redis instance:

mirror2

The actual port switching is shown in the console window in the middle of the screenshot.

The mirror function is created by passing in command line arguments when running the actual nodes. The function of server.js requires a port as a command line argument for the redis server that is attached to that specific node. Additionally a second port can be passed in to server.js which is the port that it should mirror it's data to.

Sorry about the actual size of the images in this document, zooming in it is possible to see the port numbers an any other information that should be needed from each image.

devopshw4's People

Contributors

meneal avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.