Gwadeloop.com

cherokee-admin-api part2

Today I continue to work on one of my exploratory project. I have already talked about it on this blog, its goal is to enable the dynamic generation of a cherokee configuration file. Cherokee ships with a kick ass web admin interface that make its configuration both easy and user-friendly however this interactive approach does not suit all the use cases. cherokee-admin-api makes it possible to use python to script the generation of the configuration file.

Generate a configuration file for serving a WSGI app

I have added today an example in the bitbucket repo that shows you how to generate a configuration file for cherokee to serve a wsgi app. Here it is what it take to generate and run this configuration file once cherokee-admin-api is installed :

1
2
python wsgi_conf_generator.py 
sudo cherokee -C wsgi-cherokee-gene.conf

I have written a bit of documentation on the installation process you can find it here. It uses pip and virtualenv.

Take advantage cherokee-admin to write your script

You can use cherokee admin to iteratively build your script. While developing this simple example I find myself using the cherokee-admin web interface to help me to discover the syntax expected by cherokee. The first command that is very useful is :

1
2
cherokee -C cherokee-gene.conf -t
Test on cherokee-gene.conf: OK

The above command let you test the validity of your configuration file.

Another command which helped me a lot was :

1
cherokee-admin -u -C `pwd`/wsgi-cherokee-gene.conf

Note the pwd, for some reason relative path does not work with cherokee-admin. The above command allows you to edit in place your generated configuration file and tweak it using cherokee-admin then you can use diff to see what was the modifications in the configuration file. These modifications can then be integrated back in the script used to generate the configuration file.

You can launch cherokee using your custom configuration file like this :

1
sudo cherokee -C wsgi-cherokee-gene.conf

Why to use a script to generate the cherokee configuration

There is numerous use cases where this technic can be useful :

  • you need to dynamically calculate some of the value.
  • you want to automate your deployment process

conclusion

This package is still in its infancy but please feel free to give it a spin. Do not hesitate to fork, modify and to send me a merge request.

blog comments powered by Disqus

Détail du billet

Publié le : Jui 8, 2010 à 2:33 Après-midi

© 2009 - 2012 Yann Malet