Giter Site home page Giter Site logo

decc / global-calculator Goto Github PK

View Code? Open in Web Editor NEW
24.0 17.0 21.0 62.54 MB

The source code to the web interface to the Global Calculator

Home Page: http://www.globalcalculator.org

License: Other

Ruby 10.23% C 82.39% HTML 3.40% CSS 0.01% JavaScript 3.97% Shell 0.01% Nginx 0.01%

global-calculator's Introduction

global-calculator

The source code to the web interface to the Global Calculator.

For more information about the global calculator, see: http://www.globalcalculator.org

To play with this web interface, go to: http://tool.globalcalculator.org

Canonical source: http://github.com/decc/global-calculator

Please report issues and suggest patches there.

Installing a local copy

What you need:

  1. A server with at least 4 GB and ideally 8 GB of memory
  2. Running a flavour of Unix
  3. With the standard build tools installed
  4. With version 2.1 of Ruby installed, including development headers

In the util folder is a bash script that we use to set up a Ubuntu 14.04 server to be capable of running the global calculator. This can give clues on how to get the system running.

Steps:

  1. git clone http://github.com/decc/global-calculator
  2. cd global-calculator
  3. bundle
  4. cd model/global_2050_model
  5. bundle exec rake
  6. cd ../../public/gc-anim
  7. wget -nH --cut-dirs=1 --no-parent -r http://d2ow8032j7094s.cloudfront.net/20150123/index.html # This downloads 1.5 GB of images
  8. cd ../..
  9. rackup # This starts the server

The bundle step should install all the dependencies. If it fails it may ask you to check a particular 'gem' installs manually. Doing that normally fixes the problem and the step can be repeated.

The bundle exec Rake step compiles the C version of the model. This can take tens of minutes, and requires plenty of memory.

You should now be able to browse to http://127.0.0.1:9292 and see the local copy running.

Altering the spreadsheet

If you change the spreadsheet, you need to re-translate it into its C equivalent.

To do this:

  1. change the spreadsheet in model/
  2. cd model
  3. bundle exec ruby translate_excel_into_c.rb

Note:

  1. that the C version only includes outputs that are given in named ranges starting with 'webtool'
  2. That translating a spreadsheet of this size needs at least 4 GB of RAM and can take 5 or 6 hours.

Live deployment

These are some notes on how we are deploying this live.

  1. We are using Amazon Route 53 to route requests to http://tool.globalcalculator.org to the CloudFront caching service
  2. The CloudFront caching service routes requests to an ElasticLoadBalancer
  3. The ElasticLoadBalancer routes requests to between two and twenty EC2 instances running Ubuntu 14.04
  4. The EC2 instances are running nginx. These: a. Detects requests to the public/gc-anim folder and route these to another CloudFront caching service (see gc-anim below) b. Otherwise routes requests using Passenger to versions of this code running on Ruby 2.2

The gc-anim folder

The gc-anim folder contains several GB of climate change maps. These are too large to be placed under git version control.

Instead, we store a copy of the gc-anim folder in Amazon S3. The images can be accessed at http://d2ow8032j7094s.cloudfront.net/20150123/index.html

Requests to the EC2 instance for these images get redirected by nginx to the CloudFront cache, which in turn gets them from S3.

To get a local copy of these images for offline use, follow the instructions in public/gc-anim/README.md

Scaling

The live version scales up and down using an autoscaler. This is set to watch for an alarm when the CPU load of the instances in the load balancer go above 20%, and then deploy an extra instance based on a launch configuration that uses an AMI that we have pre-prepared.

Updating

Changes to the gc-anim folder need to be re-synced with Amazon S3 (see public/gc-anim/README.md).

If the code has come from Markus's version, common things that need to change include:

  1. Removing references to _V22 in ruby code, particularly in the model folder
  2. Removing puts statements in hi-4-x.rb script
  3. Changing the global_calculator_model require in the hi-4-x.rb require_relative '../model/global_2050_model'

Changes should be tested locally, then committed to github.com

Then, deploy a new Ubuntu 14.04 instance, using the existing ami. Give that instance a public IP.

ssh into that instance, and do git pull to get the new code.

Then restart nginx sudo service nginx restart

Test whether that server seems to be providing the right result.

Then create an ami from that server.

Then create a new launch configuratio using that ami.

Then change the auto scale group to use that launch configuration.

Then kill off one of the existing running instances, and wait to see the new instance created. Check that it is using the right ami. Possibly assign it a public IP address so you can check it is serving the right things.

Then kill off any remaining running instances, and wait to see them recreated.

Check everything is working.

If not, switch the auto scale group back to the old launch configuration, then kill all the new instances.

global-calculator's People

Contributors

tamc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

global-calculator's Issues

Installation: bundle out of date

Hi there, when trying to install I got an error when running bundle (step 3 in the installation), the version of the excel_to_code gem required is 2.1.6, but this version contains code which has become depreciated.

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.