fabfile.py automation for repeating maintenance tasks¶
In our company we have automated a lot of project life cycle repeating actions. Most of them are straightforward & easy to use.
In most of projects we implement get_db and reinst_db scripts. First one downloads the most recent copy of the production database,
2nd command installs it. Typically the end user-developer needs to run this to get his project fully updated:
hg pull -uv fab get_db reinst_db depup patch
And usually in most of projects all this gets combined in a single command:
which implements the following:
- hgup - (hg pull —update) - update to most recent source code
- get_db - download latest production database
- reinst_db - drop & reinstall current database from latest backup made
- depup ~~update external source dependencies ~~ patch - apply migration patches to the project
And so Fabric abstracts it on a higher level, and makes developer life easier.
Additionally on every production server the ‘produp’ procedure gets implemented. It is very similar to
‘up’ procedure explained above, but it also includes step to reload / restart production service software
and update required files (for example static files).
- hgup * depup * patch * prod_reload * ./manage.py collectstatic