Latest Updates: svn RSS

  • Articles

    Switched to Python Fabric

    Stii 11:18 am on March 4, 2009 | Comments: 13 Permalink | Reply
    Tags: , , deployment, , , svn

    We’ve been using Capistrano to deploy Afrigator to our various servers for a while now. I can seriously not complain or say anything bad about Capistrano. Thing is, I’m more familiar with Python than I am with Ruby, thus for me it just makes more sense for me to use Fabric.

    Here is a small example of how to write a typical deploy script with Python Fabric:

    First, define your various servers which you need to deploy to. Ideally, you’ll have a test, staging and live server. Thus you’ll set them up as follows.

    def test():
        config.fab_user = 'test_user_name'
        config.fab_hosts = ['test.yourserver.com']
    
    def staging():
        config.fab_user = 'staging_user_name'
        config.fab_hosts = ['staging.yourserver.com']
    
    def live():
        config.fab_user = 'live_user_name'
        config.fab_hosts = ['www1.yourserver.com', \
    'www2.yourserver.com', 'www3.yourserver.com']
    

    This allows you to deploy your code to the various servers. Please note, you need to setup automatic login for your different servers. See here how to do automatic logins.

    Next, write the steps you would take to deploy your site manually:

    def deploy():
        "Deploy code to servers"
        msg = "deploying"
        require('fab_hosts', provided_by = [test,staging,live])
        local('svn ci -m "$(msg)"')
        run('svn export repos /path/to/repository/export/')
        run('cp -R /path/to/repository/export/* /path/to/your/site/')
    

    To deploy to the staging server you can run the following command:

    $ fab staging let:msg="Reason for check in" deploy
    

    To deploy to the 3 live servers, all you do is:

    $ fab live let:msg="Reason for check in" deploy
    

    The command works as follows: fab is the command. live/stating/test are the environments you would like to load. If you said staging, it will do the commands in deploy for the staging server. The last part is the command you want to run. In this instance, deploy.

    The let:msg=”Reason for check in” is the coolest bit! It basically allow you to override Fabric variables. If you look closely, in my deploy script I’ve set a variable msg to just say “deploy”. Now that is a stupid SVN message for a commit. In order to commit with meaningful messages, I override the msg variable with my own message. Simple, yet very effective!

    You may want to write a number of different functions in a single fabfile. If you have 100 commands and you’re not one hundred percent sure, just do a:

    $ fab list
    

    and all the commands available to you will be printed with their description. Fabric rocks! Seriously.

    Welcome back! You should subscribe to my RSS feed here.
    You should follow me on Twitter here
    You should follow me on Gatorpeeps here.

    Save Cape Town City Ballet
     
  • Articles

    Elan's SVN (Subversion) Tshirt

    Stii 5:19 pm on February 5, 2009 | Comments: 1 Permalink | Reply
    Tags: , svn,

    I’m so jealous! SVN being one of my favorite tools, Elan wore his SVN tshirt to work today and I want one! In all fairness, it is not REALLY meant to be a subversion tshirt, but for a geek like me it is! Supposed to be Sex Violence Nudity I think.

    Subversion tshirt

    Save Cape Town City Ballet
     
  • Articles

    FTP is crap! So they say in Cape Town

    Stii 8:00 am on December 15, 2008 | Comments: 0 Permalink | Reply
    Tags: , , ftp, , , svn

    FTP is crap. At least someone in Cape Town seems to think so! Found this little gem in a shopping centre in Cape Town.

    ftp

    In all fairness, its not that I believe it is crap, its just that there is so much better ways to update sites. My preference at the moment is:

    I do understand that if you host sites on a shared host you don’t always have these options and in lots of instances FTP is the only option available to you. I feel your pain :(

    Save Cape Town City Ballet
     
  • Articles

    I love SVN

    Stii 3:52 pm on December 3, 2008 | Comments: 4 Permalink | Reply
    Tags: , , svn,

    The past two days have been a complete nightmare… I’m on an important deadline when I noticed some very strange posts appear on Afrigator. Posts from sites like Mashable and Boing-Boing. Wow! They like Afrigator that much that they’ve subscribed?! Although I’d love to believe that is the case, it simply was not true… I digress.

    I started delving into our parser scripts trying to root out the problem on ground level. Make changes left, right and center. Testing, redo-ing, answering the phone, answering calls on Skype from my sweet love of my life, losing track of what I’ve done and BAM! things are a complete mess…

    So, what would be the quickest solution? Start over and do it properly. At least, for me that is sometimes the best option. Now, if you’re having nightmare days, you’ll know when it happens that you bugger shit up so badly that you’ve completely forgot to make backups before you started breaking your months of hard work. Its that sickening sinking feeling…

    Fortunately, Subversion (SVN) is not only for keeping revisions of your software, but actually allows you to go back to a snapshot of your code right about where you started doing the dumb stuff. There are a number of ways to recover, although this was what I did as a quick and dirty solution. Took me less than a minute.

    Find what the revision number is before you mucked it up.
    Export that revision to a different directory.

    svn export http://svn.afrigator.com/trunk/ -r 4815
    

    Copy the source file back to your working repository.
    Check it in

    svn ci -m "Fix the mess I made"
    

    Viola! You’re good to go and start messing it up from scratch again!

    Now I do know that the best way to prevent this from happening is to never have it happen in the first place, but hell, if and when it happens, be thankful that you’ve got SVN!

    Save Cape Town City Ballet
     

About Me

Software developer at Afrigator.com Love Python, do PHP.
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
esc
cancel