Skip to main content

Managing multiple Plone buildouts

I recently had situation in work where I needed to update several of our Plone sites with few addon products. So far we haven't thought how we'll manage our sites update story as we've basically just recently entered to the amazing world of buildouts and several Plone-sites instead of one huge plone-site with zeo.

Gotta say I had few ideas popping in my head when I was manually running buildout scripts for each of our sites and stopping and restarting them after buildout was completed. My first though was to just simply write some script which does the job and then I was already imaging some web based service so we could manage our sites buildouts ttw. Well.. that might be a bit overkill.. at least for the starters, so I went back to roots and wrote a small python application which does the job. Basically it just takes the list of buildouts and runs buildout-script with -Nv parameters and restarts the site.

Source code is below and in the github.


#!/usr/bin/python2.5

from subprocess import check_call
from subprocess import CalledProcessError

#BUILDOUT_LIST is a list of folders where you're sites are
BUILDOUT_LIST = ['Site1',
'Site2']
class Buildout:
"""Takes care of managing one buildout"""

def __init__(self, path):
self.path = path
self.dev_null = open('/dev/null','wb')

def instance_cmd(self, command):
try:
if command == 'start':
print "Starting %s instance..." % self.path
elif command == 'stop':
print "Stopping %s instance..." % self.path

check_call(['./' + self.path + '/bin/instance', command],)

except CalledProcessError, e:
print e.returncode

def run_buildout(self):
try:
print "Trying to run buildout for %s " % self.path
dev_null = open('/dev/null','wb')
check_call(['bin/buildout', '-Nv'],
cwd='./'+self.path,
stderr=dev_null, stdout=dev_null)
print "Buildout for %s completed succesfully" % self.path

except CalledProcessError, e:
print "Error while running buildout for %s: %s" % (self.path,
str(e))

class BOManager:
""" Launches buildout scripts """

def __init__(self, buildouts):
self.buildouts = buildouts

def giveitago(self):
for buildout in self.buildouts:
print "-"*40
bo = Buildout(buildout)
bo.run_buildout()
bo.instance_cmd('stop')
bo.instance_cmd('start')
print "-"*40+"\n"

if __name__ == '__main__':
buildout = BOManager(BUILDOUT_LIST)
buildout.giveitago()

Popular posts from this blog

Domain name registration through Google - when things go wrong.

Not too many people know, that you can register new domains through Google. This can be done when you're registering for Google Apps Standard Edition which is free and somewhat stripped version of their Google Apps Premium Edition. Latter one is tailored more to suit business needs.

With $10/year prize tag it's not cheapest option, but you'll get "private domain registration to protect against spam at no extra cost, full DNS control and domain management, automatically configured to work with Google services, email, calendar, instant messaging, web pages and more also at no extra charge".

As a comparsion GoDaddy offers .org domains at $14.99/year so it's actually not that bad offer. Google actually is just collecting the data and sending it to their partners (godaddy, enome) which does the registration. I decided to give it a try at January 11th. To my big surprise things didn't went that smoothly. It's been now one week since my order - the domain I …

Plone 4, ZEO and supervisor

This post belongs also to the "lessons learned" category.

With Plone 3, ZEO and supervisor combination you've probably configured your supervisor to start plone instances by running $BUILDOUT/parts/client1/bin/runzope.

Problem is that with Plone 4 your $BUILDOUT/parts/client folder doesn't contain anything else than etc folder. You know starting instances by targeting supervisor to use $BUILDOUT/bin/client1 fg doesn't work like you'd expect (supervisor would control the client1 script - not the actual plone process).

My colleague Jussi Talaskivi figured that using 'console' argument instead of 'fg' for bin/client1 script should do the trick. With 'console' argument stopping, starting and restarting Plone 4 instances with supervisor works like a charm.

Below is full example of working supervisor configuration.

[buildout] parts = supervisor [supervisor] recipe = collective.recipe.supervisor port = 8200 user = xxxx password = xxxx pr…

cd under development packages nested folders without repeating yourself

To me Plone development environment means Fedora 12, terminator and vim. As I do lots of development in the shell there has been one annoying little thing which I'm tired of - cd:ing under development packages inner structure to where the actual code lives.


Doesn't seem much but if you repeat that many times a day you'll get tired of it. Of course you can always launch vim for the package root and open the file you wanted from there, but it's still extra effort.

Few weeks ago me and my colleague Jussi Talaskivi started to think that there has to be a script which takes you to your destination simply by parsing dotted name and using information from there to cd you to the correct place. After spending some time googling around we found none. Annoyed by this we decided to do this missing script by ourself.

Soon it turned out that this wasn't that easy task as it sounds - simple shell or python script where you just parse correct path from arguments wouldn't do t…