Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| This playbook has been removed as it is now very outdated. |
| from django.core.exceptions import MiddlewareNotUsed | |
| from django.conf import settings | |
| from django.db import connection | |
| from pymongo.connection import Connection | |
| from time import time | |
| import struct | |
| import bson | |
| from bson.errors import InvalidBSON | |
| class SqldumpMiddleware(object): |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| $ sudo adduser --system --no-create-home --disabled-login --disabled-password --group redis | |
| $ sudo mv ~/init-deb.sh /etc/init.d/redis | |
| $ sudo mkdir /etc/redis | |
| $ sudo mv ~/redis.conf /etc/redis/redis.conf | |
| $ sudo chmod +x /etc/init.d/redis | |
| $ sudo chown -R redis:redis /opt/redis | |
| $ sudo touch /var/log/redis.log | |
| $ sudo chown redis:redis /var/log/redis.log | |
| $ sudo update-rc.d -f redis defaults |
| # Redis | |
| God.watch do |w| | |
| w.name = "redis" | |
| w.interval = 30.seconds | |
| w.start = "/etc/init.d/redis start" | |
| w.stop = "/etc/init.d/redis stop" | |
| w.restart = "/etc/init.d/redis restart" | |
| w.start_grace = 10.seconds | |
| w.restart_grace = 10.seconds |
| # Some basic flags | |
| use_mongomapper = false | |
| use_compass = false | |
| use_simplenavigation = false | |
| rails3_branch = false | |
| run "cp config/database.yml config/database.example.yml" | |
| # Remove redundant files | |
| remove_file "public/index.html" |
| from fabric.api import env, run, sudo, local, put | |
| def production(): | |
| """Defines production environment""" | |
| env.user = "deploy" | |
| env.hosts = ['example.com',] | |
| env.base_dir = "/var/www" | |
| env.app_name = "app" | |
| env.domain_name = "app.example.com" | |
| env.domain_path = "%(base_dir)s/%(domain_name)s" % { 'base_dir':env.base_dir, 'domain_name':env.domain_name } |
| from fabric.api import * | |
| """ | |
| Base configuration | |
| """ | |
| env.project_name = '$(project)' | |
| env.database_password = '$(db_password)' | |
| env.site_media_prefix = "site_media" | |
| env.admin_media_prefix = "admin_media" | |
| env.newsapps_media_prefix = "na_media" |
These are some notes on infrastructure & deployment.