Skip to content

Instantly share code, notes, and snippets.

@jbalogh
Forked from oremj/amodeploy.py
Created May 19, 2011 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbalogh/981479 to your computer and use it in GitHub Desktop.
Save jbalogh/981479 to your computer and use it in GitHub Desktop.
amo deploy using commander
import os
from commander.deploy import hostgroups, local_command
AMO_DIR = "/data/amo_python/src/prod/zamboni"
_amo_dir = lambda *p: os.path.join(AMO_DIR, *p)
_git_lcmd = lambda ctx, c: ctx.local("/usr/bin/git %s" % c)
def _git_checkout_tag(ctx, tag):
_git_lcmd(ctx, "fetch -t origin")
_git_lcmd(ctx, "checkout %s" % tag)
_git_lcmd(ctx, "submodule sync")
_git_lcmd(ctx, "submodule sync update --init")
@local_command
def update_code(ctx, tag, vendor_tag=None):
with lcd(AMO_DIR):
_git_checkout_tag(ctx, tag)
if vendor_tag:
with ctx.lcd("vendor"):
_git_checkout_tag(ctx, vendor_tag)
@local_command
def update_locales(ctx):
with ctx.lcd(_amo_dir(AMO_DIR, 'locale')):
ctx.local("svn revert -R .")
ctx.local("svn up")
@local_command
def disable_cron(ctx):
ctx.local("mv /etc/cron.d/addons-prod-maint /tmp/addons-prod-maint")
@local_command
def compress_assets(ctx):
with ctx.lcd(AMO_DIR):
ctx.local("python2.6 manage.py compress_assets")
@local_command
def schematic(ctx):
with ctx.lcd(AMO_DIR):
ctx.local("python2.6 ./vendor/src/schematic/schematic migrations")
@hostgroups(['amo', 'amo_gearman'])
def pull_code(ctx):
ctx.remote("/data/bin/libget/get-php5-www-git.sh")
ctx.remote("apachectl graceful")
@hostgroups(['amo_gearman'])
def restart_celery(ctx):
ctx.remote("service celeryd-prod restart")
ctx.remote("service celeryd-prod-devhub restart")
@local_command
def deploy_code(ctx):
ctx.local("/data/bin/omg_push_zamboni_live.sh")
@hostgroups(['amo_memcache'])
def clear_memcache(ctx):
ctx.remote('service memcached restart')
@hostgroups(['amo_redis'])
def clear_redis(ctx):
ctx.remote('pkill -9 -f "redis.*/amo.conf"; sleep 3; /etc/init.d/redis-amo start')
@local_command
def enable_cron(ctx):
with ctx.lcd(AMO_DIR):
ctx.local("cp scripts/crontab/prod /etc/cron.d/addons-prod-maint")
@hostgroups(['sj_amo'])
def test_command(ctx):
ctx.remote("hostname")
@local_command
def test_local_command(ctx):
ctx.local("hostname")
with ctx.lcd("/tmp/test"):
_git_checkout_tag(ctx, "2.3")
test_local_command()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment