Permalink
Browse files

Merge remote-tracking branch 'refs/remotes/playdoh/master' into develop

  • Loading branch information...
2 parents 0bb1123 + b92ec1f commit 07835638ab714d9212507a385c29220255a9db4d @Osmose Osmose committed Feb 1, 2012
View
@@ -19,7 +19,7 @@ Vagrant::Config.run do |config|
config.vm.box = "lucid32"
config.vm.box_url = "http://files.vagrantup.com/lucid32.box"
- config.vm.forward_port("web", 8000, 8000)
+ config.vm.forward_port 8000, 8000
# Increase vagrant's patience during hang-y CentOS bootup
# see: https://github.com/jedi4ever/veewee/issues/14
@@ -34,7 +34,7 @@ Vagrant::Config.run do |config|
end
# Add to /etc/hosts: 33.33.33.24 dev.playdoh.org
- config.vm.network "33.33.33.24"
+ config.vm.network :hostonly, "33.33.33.24"
config.vm.provision :puppet do |puppet|
puppet.manifests_path = "puppet/manifests"
View
@@ -0,0 +1,20 @@
+#
+# {{ header }}
+#
+
+# MAILTO=some-email-list
+
+HOME=/tmp
+
+# Every minute!
+* * * * * {{ cron }}
+
+# Every hour.
+42 * * * * {{ django }} cleanup
+
+# Every 2 hours.
+1 */2 * * * {{ cron }} something
+
+# Etc...
+
+MAILTO=root
View
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+import os
+from optparse import OptionParser
+
+from jinja2 import Template
+
+
+HEADER = '!!AUTO-GENERATED!! Edit bin/crontab/crontab.tpl instead.'
+TEMPLATE = open(os.path.join(os.path.dirname(__file__), 'crontab.tpl')).read()
+
+
+def main():
+ parser = OptionParser()
+ parser.add_option('-w', '--webapp',
+ help='Location of web app (required)')
+ parser.add_option('-u', '--user',
+ help=('Prefix cron with this user. '
+ 'Only define for cron.d style crontabs.'))
+ parser.add_option('-p', '--python', default='/usr/bin/python2.6',
+ help='Python interpreter to use.')
+
+ (opts, args) = parser.parse_args()
+
+ if not opts.webapp:
+ parser.error('-w must be defined')
+
+ ctx = {'django': 'cd %s; %s manage.py' % (opts.webapp, opts.python)}
+ ctx['cron'] = '%s cron' % ctx['django']
+
+ if opts.user:
+ for k, v in ctx.iteritems():
+ ctx[k] = '%s %s' % (opts.user, v)
+
+ # Needs to stay below the opts.user injection.
+ ctx['python'] = opts.python
+ ctx['header'] = HEADER
+
+ print Template(TEMPLATE).render(**ctx)
+
+
+if __name__ == '__main__':
+ main()
@@ -0,0 +1,14 @@
+SRC_DIR = ''
+WWW_DIR = ''
+
+CRON_NAME = ''
+
+DEPLOY_SCRIPT = ''
+REMOTE_UPDATE_SCRIPT = ''
+
+WEB_HOSTGROUP = ''
+CELERY_HOSTGROUP = ''
+CELERY_SERVICE = ''
+
+UPDATE_REF = 'origin/master'
+SSH_KEY = None
View
@@ -0,0 +1,137 @@
+"""
+Deploy this project in dev/stage/production.
+
+Requires commander_ which is installed on the systems that need it.
+
+.. _commander: https://github.com/oremj/commander
+"""
+
+import os
+import sys
+
+sys.path.append(os.path.dirname(os.path.abspath(__file__)))
+
+from commander.deploy import task, hostgroups
+import commander_settings as settings
+
+
+@task
+def update_code(ctx, tag):
+ """Update the code to a specific git reference (tag/sha/etc)."""
+ with ctx.lcd(settings.SRC_DIR):
+ ctx.local('git fetch')
+ ctx.local('git checkout -f %s' % tag)
+ ctx.local('git submodule sync')
+ ctx.local('git submodule update --init --recursive')
+
+
+@task
+def update_locales(ctx):
+ """Update a locale directory from SVN.
+
+ Assumes localizations 1) exist, 2) are in SVN, 3) are in SRC_DIR/locale and
+ 4) have a compile-mo.sh script. This should all be pretty standard, but
+ change it if you need to.
+
+ """
+ with ctx.lcd(os.path.join(settings.SRC_DIR, 'locale')):
+ ctx.local('svn up')
+ ctx.local('./compile-mo.sh .')
+
+
+@task
+def update_assets(ctx):
+ with ctx.lcd(settings.SRC_DIR):
+ # LANG=en_US.UTF-8 is sometimes necessary for the YUICompressor.
+ ctx.local('LANG=en_US.UTF8 python2.6 manage.py compress_assets')
+
+
+@task
+def update_db(ctx):
+ """Update the database schema, if necessary.
+
+ Uses schematic by default. Change to south if you need to.
+
+ """
+ with ctx.lcd(settings.SRC_DIR):
+ ctx.local('python2.6 ./vendor/src/schematic/schematic migrations')
+
+
+@task
+def install_cron(ctx):
+ """Use gen-crons.py method to install new crontab.
+
+ Ops will need to adjust this to put it in the right place.
+
+ """
+ with ctx.lcd(settings.SRC_DIR):
+ ctx.local('python2.6 ./bin/crontab/gen-crons.py -w %s -u apache > '
+ '/etc/cron.d/.%' % (settings.WWW_DIR, settings.CRON_NAME))
+ ctx.local('mv /etc/cron.d/.%s /etc/cron.d/%s' %
+ (settings.CRON_NAME, settings.CRON_NAME))
+
+
+@task
+def checkin_changes(ctx):
+ """Use the local, IT-written deploy script to check in changes."""
+ ctx.local(settings.DEPLOY_SCRIPT)
+
+
+@hostgroups(settings.WEB_HOSTGROUP, remote_kwargs={'ssh_key': settings.SSH_KEY})
+def deploy_app(ctx):
+ """Call the remote update script to push changes to webheads."""
+ ctx.remote(settings.REMOTE_UPDATE_SCRIPT)
+ ctx.remote('/bin/touch %s' % settings.REMOTE_WSGI)
+
+
+@hostgroups(settings.CELERY_HOSTGROUP, remote_kwargs={'ssh_key': settings.SSH_KEY})
+def update_celery(ctx):
+ """Update and restart Celery."""
+ ctx.remote(settings.REMOTE_UPDATE_SCRIPT)
+ ctx.remote('/sbin/service %s restart' % settings.CELERY_SERVICE)
+
+
+@task
+def update_info(ctx):
+ """Write info about the current state to a publicly visible file."""
+ with ctx.lcd(settings.SRC_DIR):
+ ctx.local('date')
+ ctx.local('git branch')
+ ctx.local('git log -3')
+ ctx.local('git status')
+ ctx.local('git submodule status')
+ ctx.local('python2.6 ./vendor/src/schematic/schematic -v migrations/')
+ with ctx.lcd('locale'):
+ ctx.local('svn info')
+ ctx.local('svn status')
+
+ ctx.local('git rev-parse HEAD > media/revision.txt')
+
+
+@task
+def pre_update(ctx, ref=settings.UPDATE_REF):
+ """Update code to pick up changes to this file."""
+ update_code(ref)
+ update_info()
+
+
+@task
+def update(ctx):
+ update_assets()
+ update_locales()
+ update_db()
+
+
+@task
+def deploy(ctx):
+ install_cron()
+ checkin_changes()
+ deploy_app()
+ update_celery()
+
+
+@task
+def update_site(ctx, tag):
+ """Update the app to prep for deployment."""
+ pre_update(tag)
+ update()
@@ -29,7 +29,7 @@
ubuntu: {
package { "apache2-dev":
ensure => present,
- before => File['/etc/apache2/sites-enabled/playdoh.conf'];
+ before => File['/etc/apache2/sites-enabled/playdoh.conf'];
}
file { "/etc/apache2/sites-enabled/playdoh.conf":
@@ -40,6 +40,13 @@
];
}
+ exec {
+ 'a2enmod rewrite':
+ onlyif => 'test ! -e /etc/apache2/mods-enabled/rewrite.load';
+ 'a2enmod proxy':
+ onlyif => 'test ! -e /etc/apache2/mods-enabled/proxy.load';
+ }
+
service { "apache2":
ensure => running,
enable => true,
@@ -48,6 +55,7 @@
File['/etc/apache2/sites-enabled/playdoh.conf']
];
}
+
}
}
}
@@ -10,7 +10,7 @@
}
exec { "create_mysql_database":
- command => "mysqladmin -uroot create $DB_NAME",
+ command => "mysql -uroot -B -e'CREATE DATABASE $DB_NAME CHARACTER SET utf8;'",
unless => "mysql -uroot -B --skip-column-names -e 'show databases' | /bin/grep '$DB_NAME'",
require => File["$PROJ_DIR/settings/local.py"]
}
2 vendor
Submodule vendor updated 1 files
+1 −1 src/django-nose
View
@@ -1,7 +1,9 @@
import os
import site
-os.environ['CELERY_LOADER'] = 'django'
+os.environ.setdefault('CELERY_LOADER', 'django')
+# NOTE: you can also set DJANGO_SETTINGS_MODULE in your environment to override
+# the default value in manage.py
# Add the app dir to the python path so we can import manage.
wsgidir = os.path.dirname(__file__)

0 comments on commit 0783563

Please sign in to comment.