I dev on a VM that has at least two projects running with incompatible apache httpd.conf files. The differences include User/Group, Location etc, so I switch between the configs and then restart apache httpd when I want to work on a particular project.
Firstly, I understand that some or all of my different settings could be merged into one conf file and made to work on different virtual hosts etc, but in some situations you can't do this because: you only want one project running off your dev server at a time due to performance/load issues; or you have a specific file you need to use as a httpd conf file from your codebase etc.
So - I used git to help me switch between configs.
# cd /etc/apache2
# git add apache2.conf
# git commit
# git tag projA
# vim apache2.conf # or cp your apache2.conf for projB into place
# git add apache2.conf
# git commit
# git tag projB
# echo "/etc/init.d/apache2 restart" > .git/hooks/post-checkout
# chmod a+x .git/hooks/post-checkout
... now you are setup! So when you want to switch to projA you do this:
# cd /etc/apache2 && git checkout projA
... and to switch back to projB use:
# cd /etc/apache2 && git checkout projB
... and your apache will automatically restart after each checkout.
Yes you could do this just by copying your files into place but I think this is a neat use of git and one that will scale over many projects and many revisions of the conf files.
UPDATE
Instead of using tags, use branches! That way you can update the conf files, commit, and then continue using the projA and projB identifiers.
Git just keeps rocking my world.
OK, here is how I deploy my blog and here is how git saved me last night when the deployment went bad:
I git-pull into a webroot directory (well, the directory that is setup to serve my python) from my main git repo (which is also hosted on the same machine.)
When I updated the blog software last night I did a git-pull, restarted apache and saw the error (yes I should've caught it in dev, shoulda-coulda-woulda but-but-but.)
So, error noted. What do I do to rollback to the last working version?
$ git log
... and I copy the SHA hex-string of the last working commit. Then we rollback with:
$ git checkout <copied_hex_string>
... and restart apache. Ta-da! Now the blog is still up while I do the bug fix.
OK so what happens when I've commited the fix and I want to make the blog update?
$ git pull
... puts all the new changes in the git repo but doesn't fast-forward it to the HEAD of master automatically. Why? Because you aren't in master anymore - you've checked out a previous commit. So all you need to do now is:
$ git checkout master
... restart apache and you're set.
EDIT: Here is some info to rollback to the previous commit in a more general way:
$ git checkout HEAD~1
... # you are now at the previous version
$ git checkout master
... # you are now back to the latest version
There is a module called mod_throttle that apparently works for Apache 1.3 (but I'm on 2) but that's not what I'm talking about in this post anyway. I'm talking about limiting memory usage of the httpd processes. You can do this by adding:
RLimitMEM 307200 358400
... to the httpd.conf file. (Numbers are measured in bytes.)
The first parameter sets the soft resource limit for all processes and the second parameter sets the maximum resource limit. Either parameter can be a number, or max to indicate to the server that the limit should be set to the maximum allowed by the operating system configuration. Raising the maximum resource limit requires that the server is running as root, or in the initial startup phase.
Hopefully this will stop some run-away mod_perl processes on my low-memory VM from eating up all the memory and swapping heavily (to the extent that I can't even type into the console when it happens.) We'll see how it works out!
Django Python 960.gs Git Vim NetBSD Nginx
The author is a software engineer living in Australia. He sux at guitar, loves camping, doesn't like cake, does like coffee and is a lazy home brewer.
Help
Latest entries
*BSD Agile Apache Apple Athletics Beer Best-Practice Censorship Comedy Cool Crosswords Deployment Django English Exim Firefox Git Hardcore Health Interface irssi Javascript Jira Languages Linux Makefile Markdown Mathematics Mobile Broadband MySQL NetBSD nginx Nokia OSX Perl Photo Privacy Python Rant Requirements rsync Ruby Shell Slackware SQL SQLite SSH Standards Subversion Testing ThisBlog Vim VMWare (Fusion) VPN WDTEM X Yum zsh
Perldoc Output
Yum
Possum
Git's Index
Jira Project Keys
The Coffee Shop
Git GUI
It is more important...
Questioning Unix (and Other) File Times
The Frog King Photo
Rain Cloud Photo
rsync
Timezone
utf8 in your Perl
Theatre Ceiling Photo
Some problems are so complex...
Colours in your PAGER
zsh vared
zsh magic-equals and double-star
Funny Tweets
ChoppingBoard, Project365, RageQuit