How to use¶
There are a couple of steps:
- set up a project using the `django-scm-projecttemplate`_. Please check the project’s documentation on how to use it.
- Make sure the deploytools are added to the INSTALLED_APPS of your project (that should already be the case if you use django-scm-projecttemplate). The best way to do this is by using pip (in a virtual environment):
pip install -e https://bitbucket.org/flenter/django-scm-deploytools/
After that, run the management command ‘create_deploy_tools’ like so:
python manage.py create_deploy_tools
This will create a couple of important files and folders:
- a project_name/fabfile.py which contains the core logic for installing the required software and adding sites to existing servers. This fabfile is good enough for most projects, but can should be modified/customized if need be.
- deploy folder which (amongst others) contains servers.py.
- create a script in the virtualenv’s bin/deploy_project_name (which makes it easier to use fabric and the fabfile). It is similar to calling cd /project_root && ../bin/fab etc etc..
Adding the settings for a deploy target (such as live, staging etc) can be done like this:
python manage.py add_deploy_target
A couple of questions will need to be answerd (asking about the hostname, domain_name etc) and modifies deploy/servers.py file accordingly. After this you should be ready to go. You can view a list of commands by typing:
deploy_project_name -l
Resulting in:
Fabric install/update script for scm's django servers
Available commands:
add_site Adds a site to an already prepared server.
collect_static Runs the 1.3 collectstatic manage.py command
full_install Do full installation
live Deploy to:: cola.secretcodemachine.com
update_site Rsync the site and stop/start gunicorn
The newly created deploy target should be listed there. Actually deploying or updating a site are two commands chained together. The first command being the deploy target (the one you have created earlier with the add_deploy_target command). Resulting in commands like the following:
deploy_project_name staging full_install
# or adding a site to a server that already contains virtualenv/mysql
deploy_project_name staging add_site
# update an existing site by running
deploy_project_name staging update_site
Some details to remember for updating a site: a snapshot of the current code will be made (the media folder is not included in this). Should the unit test fail, a rollback will be attempted.
This means it will be attempted to go back to the pre-update stored south migrations, please keep that in mind when creating the migrations.