Skip to content

Webfaction Deployment Notes

ghing edited this page Nov 13, 2012 · 5 revisions

Downloaded Packages

I'm storing these in ~/packages

Solr

Version: 3.6.1

I mostly worked from the documentation at http://wiki.apache.org/solr/SolrJetty

Solr is installed in ~/webapps/solr I'll refer to this as SOLR_HOME. The files in this directory are the contents of the example directory in the Solr distribution

I'm starting Solr's process using the init script in ~/bin/jetty.sh

The configuration for the script is in ~/etc/default/jetty which is symlinked from ~/.jettyrc. The jetty.sh script expects to find the configuration there

I made a simple script to check that Jetty is running and to start it if not. This script lives in ~/bin/check_solr.sh. I made a crontab entry to run this script every 20 minutes:

# Check that Solr's jetty is running and start it if it's not
*/20 * * * * ~/bin/check_solr.sh

Jetty

Update: I'm using the prepackaged Solr/Jetty example disributed with Solr, but keeping these docs and the application installed (for now)

Jetty is installed in /home/floodlight/webapps/jetty

I'll call this JETTY_HOME from now on (which is actually the configuration variable used to point the scripts that starts jetty to the installation)

This directory was created when I created a "custom app" for Jetty in the Webfaction admin panel

I'm starting jetty using the script JETTY_HOME/bin/jetty.sh

The configuration for the script is in ~/etc/default/jetty which is symlinked from ~/.jettyrc. The jetty.sh script expects to find the configuration there

Python

Version: 2.7

Webfaction provides documentation for installing python libraries http://docs.webfaction.com/software/python.html

Global packages are installed in ~/lib/python2.7

I installed the following packages globally:

  • pip
  • virtualenv

I created a virtualenv for the app within the app's root directory. The virtualenv is in ~/webapps/floodlight_staging/venv and was created with this command:

virtualenv --python=python2.7 --distribute --no-site-packages venv

I activated the virtualenv and installed Floodlight's Python dependencies with pip install -r REQUIREMENTS while in the checked out project directory.

Important pip install -r REQUIREMENTS file installs PIL without JPEG support on Webfaction. I tried a few things to get PIL installed and then gave up and just did ``pip uninstall pil && pip install pillow` which seemed to just work.

Mercurial

Some of the Floodlight dependencies are installed by pip via a Mercurial repository. To make this work, I had to install Mercurial following the directions at http://docs.webfaction.com/software/mercurial.html

Floodlight App

The root directory of the app is ~/webapps/floodlight_staging

This directory was created by creating a mod_wsgi 3.4/Python 2.7 app in the Webfaction Panel

The Django project is checked out in ~/webapps/floodlight_staging/floodlight

I had to edit the Apache configuration file in ~/webapps/floodlight_staging/apache/conf/httpd.conf to set environment variables and point Apache to the wsgi.py for the app.

I had to create ~/webapps/floodlight_staging/floodlight/wsgi.py and point it at the app's directory and Django settings module

I created instance-specific settings in ~/webapps/floodlight_staging/floodlight/settings/staging.py

Floodlight Static/Media

I created 2 applications in the Webfaction panel floodlight_staging_static and floodlight_staging_media. I made two so I could mount them at their own top-level paths (/static/ and /media/ respctively)

I edited ~/webapps/floodlight_staging/floodlight/settings/staging.py and set these settings to point to the apps for static and media assets:

STATIC_ROOT = '/home/floodlight/webapps/floodlight_staging_static/'
MEDIA_ROOT = '/home/floodlight/webapps/floodlight_staging_media/'

STATIC_URL = '/static/'
MEDIA_URL = '/media/'

I granted apache write access to the media directory following the instructions at http://docs.webfaction.com/software/static.html#granting-apache-write-access

Memcached

I'm using Memcached to avoid some of the more expensive database queries in the Explore view. Memcached is already installed on Webfaction, so I just had to install python-memcached in each instance's virtualenv:

pip install python-memcached

Backups

Webfaction makes daily keeps system-wide backups and keeps them for 10 days. I'm also making nightly database-only backups and saving them in ~/backups/