# Codespeed Example instance
Codespeed uses the Web framework [Django](http://djangoproject.com/). To get a
Codespeed instance running you need to set up a Django Project. This directory
is just such a project for your reference and a jump start to create your own.
## For the impatient
Warning: It is recommended to use [virtualenv](http://pypi.python.org/pypi/virtualenv) to avoid installing
stuff on the root path of your operating system.
However, it works also this way and might be desired in production
environments.
### Testing with the built-in Development Server
That will give you *just* the Django development server version. Please
refer to *Installing for Production* for serious installations.
It is assumed you are in the root directory of the Codespeed software.
1. Install the Python pip module
`which pip >/dev/null || easy_install pip`
(You might be required to use sudo)
2. You *must* copy the `sample_project` directory to your project. (Prevents updates on
git tracked files in the future.) Let's call it speedcenter
`cp -r sample_project speedcenter`
3a. (When configuring your own project) `pip install codespeeed`
3b. (For Codespeed development) Install Django and other dependencies using pip
`pip install -r requirements.txt`. This will not install codespeed itself, as we want runserver to only "see" the local codespeed copy
4. Add codespeed to your Python path
Either
`export PYTHONPATH=../:$PYTHONPATH`
or
`ln -s ./codespeed ./sample_project`
5. Initialise the Django Database
`python manage.py syncdb`
(Yes, add a superuser.)
`python manage.py migrate`
Optionally, you may want to load the fixture data for a try
`python manage.py loaddata ../codespeed/fixtures/testdata.json`
6. Finally, start the Django development server.
`python manage.py runserver`
7. Enjoy.
`python -m webbrowser -n http://localhost:8000`
## Installing for production
There are many choices to get Django Web apps served. It all depends on
your preferences and existing set up. Two options are shown. Please do
not hesitate to consult a search engine to tune your set-up.
### NGINX + GUNICORN: Easy as manage.py runserver
Assumed you have a [Debian](http://www.debian.org) like system.
1. Follow the steps from the development server set-up up to the the 6th step (database init).
2. Install [nginx](http://nginx.net/) and [gunicorn](http://gunicorn.org/)
`sudo apt-get install nginx gunicorn`
3. Tune /etc/nginx/sites-enabled/default to match
deploy/nginx.default-site.conf
(Hint: See diff /etc/nginx/sites-enabled/default deploy/nginx.default-site.conf
for changes)
Note, the sitestatic dir needs to point to your speedcenter/sitestatic dir!
4. Restart nginx
/etc/init.d/nginx restart`
5. Prepare static files
`cd /path/to/speedcenter/`
`python ./manage.py collectstatic`
6. Add 'gunicorn' to your INSTALLED_APPS in settings.py
INSTALLED_APPS = (
'django.contrib.auth',
[...]
'south',
'gunicorn'
)
6. Run speedcenter by
`python ./manage.py run_gunicorn`
7. Check your new speedcenter site! Great! But wait, who runs gunicorn after the
terminal exits?
There are several options like upstart, runit, or supervisor.
Let's go with supervisor:
1.