Package: silk-deployment
OverviewSilk is aFabricbased tool for setting up Python WSGI apps on what I like to
call the SNUG stack:Supervisordfor starting processes and keeping them alive.Nginxfor proxying between your WSGI app and the big bad web.Ubuntuas the OS of choice, enabling resolution of system dependencies with
apt.  Debian might work as well but hasn’t been tested.Gunicornfor serving your WSGI app.(I suppose it could also be the GUNS stack but that sounds far less friendly.)Key FeaturesDeploy your site to one or more servers with a single command (‘silk push’).Automatic configuration of Nginx, Supervisord, and Gunicorn to get your site running.Isolation of each site into a separateVirtualenvSupport for differing app config depending on which role you deploy to (a
different DB in staging than production, for example).InstallationUse pip:pip install silk-deploymentYou can also install the current development version straight from bitbucket:pip install hg+http://bits.btubbs.com/silk-deployment#egg=silk-deploymentCommands(Almost) all of the commands below require that you specify a role name, like
‘silk dosomething -R dev’.Commands can generally be run from the site root directory or any subdirectory
of it.pushsilk push -R rolenameThis command is the main reason for Silk’s existence. It does the work required
to get your app running on a host (or set of hosts) given the configuration
specified in site.yaml and the selected role .yaml file.  ‘push’ does the
following:SSHes to the remote server(s) specified in the role config.Copies the site from your local machine to a temporary directory on the
remote server.Creates a virtualenv for the site.Installs python dependencies into the virtualenv.Writes config file includes for nginx and supervisord.Writes a supervisord config for the site and starts it up.Makes a request to the homepage to ensure the site is running.Tells nginx to route traffic to the new instance instead of the old one.runsilk run -R rolenameThis command runs the site from the local machine, on port 8000.  (Nothing is
pushed of copied.)  Static directories listed in thestatic_dirssection of
site.yaml will also be served.  (CherryPy is used for this magic.)skelsilk skel sitenameCreates a directory with a basic Silk file and directory structure.LayoutA silk-enabled project should be layed out something like this:mysite.com
├── fabfile.py
├── membrane.py
├── requirements.txt
├── roles
│   ├── dev.yaml
│   ├── staging.yaml
│   └── production.yaml
├── site.yaml
└── my-django-projectSome of those files/folders are required, other are optional:Requiredsite.yaml - This is the main config file (comparable to app.yaml in Google
App Engine)requirements.txt - A pip-compatible list of Python package names and
versions.roles/*.yaml - One or more ‘role’ files that contain the config to be
passed into your app depending on the deployment context.All of the required files will be created for you with the ‘silk skel’ command.Optionalmembrane.py - For Django projects it’s nice to have a little shim to expose
the project as a WSGI app.  I like to call mine membrane.py.  You can use
whatever you like, or nothing at all, depending on your setup.my-django-project - Silk isn’t restricted to Django; any valid WSGI app on
your Python path should be servable.  But for Django projects I think it
makes sense to stick them right there.fabfile.py - AFabric-compatible fabfile that imports Silk’s Fabric
functions.  This is where you can customize Silk’s ‘push’ function by
wrapping it with your own (I do this to run Django’s “collectstatic” on
push), or add in your own Fabric tasks.