Created
May 17, 2011 19:25
-
-
Save oremj/977179 to your computer and use it in GitHub Desktop.
Revisions
-
oremj revised this gist
May 24, 2011 . 1 changed file with 27 additions and 29 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,53 +1,58 @@ import os from commander.deploy import hostgroups, task 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 update --init") @task def update_code(ctx, tag, vendor_tag=None): with ctx.lcd(AMO_DIR): _git_checkout_tag(ctx, tag) if vendor_tag: with ctx.lcd("vendor"): _git_checkout_tag(ctx, vendor_tag) @task def update_locales(ctx): with ctx.lcd(_amo_dir(AMO_DIR, 'locale')): ctx.local("svn revert -R .") ctx.local("svn up") @task def disable_cron(ctx): ctx.local("mv /etc/cron.d/addons-prod-maint /tmp/addons-prod-maint") @task def enable_cron(ctx): with ctx.lcd(AMO_DIR): ctx.local("cp scripts/crontab/prod /etc/cron.d/addons-prod-maint") @task def compress_assets(ctx): with ctx.lcd(AMO_DIR): ctx.local("python2.6 manage.py compress_assets") @task def schematic(ctx): with ctx.lcd(AMO_DIR): ctx.local("python2.6 ./vendor/src/schematic/schematic migrations") @hostgroups(['amo', 'amo_gearman'], remote_limit=5) def pull_code(ctx): ctx.remote("/data/bin/libget/get-php5-www-git.sh") ctx.remote("apachectl graceful") @@ -59,9 +64,10 @@ def restart_celery(ctx): ctx.remote("service celeryd-prod-devhub restart") @task def deploy_code(ctx): ctx.local("/data/bin/omg_push_zamboni_live.sh") pull_code() @hostgroups(['amo_memcache']) @@ -74,21 +80,13 @@ def clear_redis(ctx): ctx.remote('pkill -9 -f "redis.*/amo.conf"; sleep 3; /etc/init.d/redis-amo start') @task def update_amo(ctx, tag, vendor_tag): disable_cron() update_code(tag, vendor_tag) update_locales() compress_assets() schematic() deploy_code() restart_celery() enable_cron() -
oremj created this gist
May 17, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,94 @@ 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(): with lcd(AMO_DIR): 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()