Codespeed uses the Web framework Django. 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.
Warning: It is recommended to use 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.
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.
- Install the Python pip module
which pip >/dev/null || easy_install pip
(You might be required to use sudo) - You must copy the
sample_project
directory to your project. (Prevents updates on git tracked files in the future.) Let's call it speedcentercp -r sample_project speedcenter
3a. (When configuring your own project)pip install codespeeed
3b. (For Codespeed development) Install Django and other dependencies using pippip install -r requirements.txt
. This will not install codespeed itself, as we want runserver to only "see" the local codespeed copy - Add codespeed to your Python path
Either
export PYTHONPATH=../:$PYTHONPATH
orln -s ./codespeed ./sample_project
- 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 trypython manage.py loaddata ../codespeed/fixtures/testdata.json
- Finally, start the Django development server.
python manage.py runserver
- Enjoy.
python -m webbrowser -n http://localhost:8000
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.
Assumed you have a Debian like system.
- Follow the steps from the development server set-up up to the the 6th step (database init).
- Install nginx and gunicorn
sudo apt-get install nginx gunicorn
- 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!
- Restart nginx /etc/init.d/nginx restart`
- Prepare static files
cd /path/to/speedcenter/
python ./manage.py collectstatic
- Add 'gunicorn' to your INSTALLED_APPS in settings.py INSTALLED_APPS = ( 'django.contrib.auth', [...] 'south', 'gunicorn' )
- Run speedcenter by
python ./manage.py run_gunicorn
- 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:
- + to exit gunicorn
apt-get install supervisor
cp deploy/supervisor-speedcenter.conf /etc/supervisor/conf.d/speedcenter.conf
$EDITOR /etc/supervisor/conf.d/speedcenter.conf #adjust the path
supervisorctl update
supervisorctl status
speedcenter RUNNING pid 2036, uptime 0:00:05
- Warning: You may find another way to run gunicorn using
gunicorn_django
. That might have a shebang of#!/usr/bin/python
bypassing your virtualenv. Run it out of your virtualenv bypython $(which gunicorn_django)
If you don't like surprises and are not into experimenting go with the old work horse. Assumed you have a Debian like system.
- Follow the steps from the development server set-up
- Prepare static files
cd /path/to/speedcenter/
python ./manage.py collectstatic
- Install apache and mod_wsgi
apt-get install apache2 libapache2-mod-wsgi
- Copy deploy/apache-speedcenter.conf
cp deploy/apache-speedcenter.conf /etc/apache2/sites-available/speedcenter.conf
- Edit /etc/apache2/sites-available/speedcenter.conf to match your needs
- Enable the new vhost
a2ensite speedcenter.conf
- Restart apache
/etc/init.d/apache2 restart
- Check your new vhost.
Just edit your very own Django templates in speedcenter/templates
. A good
start is codespeed/base.html
the root of all templates.
If you need to change the codespeed templates:
- Copy the templates from the codespeed module into your Django project folder.
cp -r codespeed/templates/codespeed speedcenter/templates/
- Edit the templates in speedcenter/templates/codespeed/*html Please, also refer to the [Django template docu] (http://docs.djangoproject.com/en/1.4/ref/templates/)
If you don't want to have your speedcenter in the root url you can change urls.py.
Comment (add a '#' at the beginning) line number 25 (r'^', include('cod...
and uncomment the next line (r'^speed/', include('cod...
(Note, Python is
picky about indentation).
Please, also refer to the [Django URL dispatcher docu]
(http://docs.djangoproject.com/en/1.4/topics/http/urls/).
The main config file is settings.py
. There you configure everything related
to your set up.