Getting an ABCE simulation on-line

Prepare your simulation to be displayed on the web

In order for your simulation to be able to be run on the web it must be running in the web browser. For this the file should be like it was in the template, and from abce.abcegui import app must be added after the other import statements:

from __future__ import division
from abce.abcegui import app

title = "Computational Complete Economy Model on Climate Gas Reduction"
text = """ This simulation simulates climate change

simulation_parameters = OrderedDict({'wage_stickiness': (0, 0.5, 1.0),
                                     'price_stickiness': (0, 0.5, 1.0),
                                     'network_weight_stickiness': (0, 0.5, 1.0),
                                     'carbon_tax': (0, 50.0, 80.0),
                                     'tax_change_time': 100,
                                     'rounds': 200})

@gui(simulation_parameters, text=text, title=title, self_hosted=False)
def main(simulation_parameters):

    simulation = Simulation(rounds=simulation_parameters['rounds'], trade_logging='group', processes=1...

    #simulation.graphs() This must be commented out or deleted

if __name__ == '__main__':

It is important to note that the main() function is not called, when is imported! if __name__ == '__main__':, means that it is not called when is imported. you can also simply delete the call of main().

@gui is the part that generates the web application in the imported app container. self_hosted must be set to False in @gui(simulation_parameters, text=text, title=title, self_hosted=False). If self_hosted is not False, the simulation will generate results, but not change to the result view.

The easiest way to get your code to the server is via github. For this follow the following instructions. Push the simulation to github. If you are unsure what git and github is, refer to this `<>`_. If your code is not yet a git repository change in your directory:

git init
git add --all
git commit -m"initial commit"

Go to github sign up and create a new repository. It will than display you instruction how to push an existing repository from the command line your, they will look like this:

git remote add origin
git push -u origin master

Deploy you ABCE simulation on amazon ec2 or your own Ubuntu server

For a detailed explanation refer `here<>`_

create an amazon ec2 instance following `Amazon’s tutorial here<>`_

make sure that in step 7b, configure the security groups, such that you have a HTTP access. This setting allows access to port 80 (HTTP) from anywhere, and ssh access only from your IP address.


then from the console ssh into your account

ssh -i amazoninstanceweb2py.pem

Install the server software and ABCE requirements:

sudo apt-get update
sudo apt-get install python-pip python-dev nginx

sudo apt-get install python-pandas
sudo pip install --upgrade numpy
sudo apt-get install git

sudo pip install virtualenv

copy or clone your ABCE simulation into the ~/myproject directory the easiest way is to use a git repository, but you can also use scp:

git clone

change into your project and create and activate a python virtual environment:

cd ~/myproject

virtualenv myprojectenv
source myprojectenv/bin/activate

Your prompt will change to indicate that you are now operating within the virtual environment. It will look something like this (myprojectenv)user@host:~/myproject$.

Install Flask into your environment:

pip install uwsgi flask

Install abce:

cd ~/abce
python install
cd ~/myproject

Create and wsgi entry point:

nano ~/myproject/

In the editor type this:

from start import app as application

if __name__ == "__main__":

-> ctrl-x -> y -> enter, to save

deactivate the virtual environment:


Creating a uWSGI Configuration File

nano ~/myproject/myproject.ini

Copy this in:

module = wsgi

master = true
processes = 5

socket = myproject.sock
chmod-socket = 660
vacuum = true

die-on-term = true

Create an Upstart Script:

sudo nano /etc/init/myproject.conf

Copy this in and change the paths, myproject and possibly the user name:

description "uWSGI server instance configured to serve myproject"

start on runlevel [2345]
stop on runlevel [!2345]

setuid ubuntu
setgid www-data

env PATH=/home/ubuntu/myproject/myprojectenv/bin
chdir /home/ubuntu/myproject
exec uwsgi --ini myproject.ini

Try to start with:

sudo start myproject

If it doesn’t start your myproject.conf is probably somehow wrong.

Configuring Nginx to Proxy Requests

sudo nano /etc/nginx/sites-available/myproject

type in, replace the IP and directory:

server {
    listen 80;

    location / {
        include uwsgi_params;
        uwsgi_pass unix:/home/ubuntu/myproject/myproject.sock;


Link the project as active:

sudo ln -s /etc/nginx/sites-available/myproject /etc/nginx/sites-enabled

Check the configuration:

sudo nginx -t

Restart with new configuration:

sudo service nginx restart

Check in the browser whether it works, put or what ever your ip is into the address bar.

If it says internal server error check the logs:

sudo more /var/log/upstart/myproject.log

If its a python error restart with:

sudo restart myproject

If that doesn’t work you can also reboot:

sudo reboot now