SVN and Web
In an attempt to apply versioning to web development, we've set up a system where instead of uploading changes to a web server, the developers check changes into a SVN repository. The changes are then applied to the web server. We've done this for a while with our development web server, but it's become apparent that it's really too tedious. We're going to apply it to the production web server and remove it from the development web server.
How to Set it Up
- set up svn repo
- set post-commit hook on svn repo to poke the web server (we poke the webserver by touching a file)
- set up ssh keys and whatnot to allow post-commit hook to poke the web server (assuming SVN repo is on different server from web server)
- set up simple script to use inotify to watch if touched file has been poked and launch update script
- set up update script to do SVN update and launch setup script
- set up setup script to take updated SVN working copy and install into web directories with correct permissions etc...
Sample inotify script
POKE=/home/webmaster/.poke UPDATER=/home/webmaster/update.sh UPDATER_SHORTNAME=`basename $UPDATER` while inotifywait -q $POKE ; do $UPDATER || exit done &
Rollback
In order to make it possible for non-Dylan people to do something if this all goes horribly wrong, I've written a simple script called rollback which rolls back the /home/webmaster/webroot SVN working directory by one step. If you run it twice, you go back two steps etc... It uses sudo and I've changed the sudoers file so that if Shelly or Rick runs it they won't be prompted for a password. So, if someone does an SVN update and the web page gets totally hosed, Shelly or Rick could ssh to tintin and type "rollback" and it has a fighting chance of making everything OK.
The obvious solution to the problem addressed by this script was to make a web interface, but that's really overkill. Shelly and Rick can use SSH. And if I decide I want to make a web interface, I can have it call this script and save myself doing the work twice.
Failing that, they can still SFTP to Tintin and upload files in the old way.
