One Click Django Project Publishing
I was reading The Joel Test and I got to number #2 which says "Can you make a build in one step?" My initial thought was that there aren’t really builds per se in web applications (unless you use ASP.NET). But then I thought, I wonder if I could make publishing my Django application a one step process. So that’s what I set out to do.
Here are the manual steps I go through to publish my Django App:
- Commit my code changes to Subversion (I use TortoiseSVN ā Yes, I’m running Windows)
- Log in to my Webfaction account via SSH using PuTTy.
- Run a subversion update on media folder
- Back up my settings.py file for good measure
- Run a subversion update on my Django application folder
- If there were model additions, run manage.py syncdb
- Restart apache for good measure
Ok, so maybe the title of this post is a bit misleading because I did not automate step one. Let me explain why though. When I commit code, I sometimes leave debug code in where I don’t want to. I live to verify that I’m not committing changes that shouldn’t be there so I often look at diff files in TortoiseSVN before I commit. That’s just one step that I prefer to keep my eyes on. I suppose you could say that it’s not really part of the publishing process and we assume that publishing comes after committing code changes then yeah, it’s still one step.
My solution is actually a combination of two scripts. I found this app called Plink that is basically PuTTy for your command line. Inside my Django project folder I’ve created a batch script called publish.bat which contains the following:
@echo off
plink -ssh MYDOMAIN.com -l MYLOGIN -pw MYPASSWORD ./update.sh
pause
This essentially logs in to my server via SSH and runs a shell script. Here are the contents of that shell script:
cd webapps/media
svn update
cd ../myapp/myapp
cp settings.py settings.backup.py
svn update
python2.5 manage.py syncdb
../apache2/bin/restart
That’s basically it. Now I just commit my code and when I want to publish I just double-click on publish.bat and I’m done.
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.
May 15, 2009
Ā·
Dustin Ā·
20 Comments
Tags: django, plink, putty, ssh, subversion, webfaction, windows Ā· Posted in: Programming & Internet
-
http://arthurkoziel.com Arthur
-
http://squarefactor.com bill
-
http://www.jonasundderwolf.de Jonas
-
http://jetfar.com Rich
-
http://jetfar.com Rich
-
http://melbourne.at9t.com/ 墨å°ę¬
-
vishal
-
http://www.drivenz.co.nz/home/ Melvin@Car Hire New Zealand
-
http://nicheblueprint2bonus.org Alex @ Niche Blueprint 2 Bonus
-
http://tzangms.com tzangms
-
Craig @ Instant Money Code Bonus
-
ismail
-
Anonymous
-
Anonymous
-
Anonymous
-
http://www.farmvillenews.net FarmVille News
-
shadrach lamuel
-
Anonymous
-
UGG Bailey Button Triplet


